Comparing version 0.0.6 to 0.1.0
{ | ||
"name": "typemoq", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "A simple mocking library for TypeScript", | ||
@@ -8,2 +8,3 @@ "author": "Florin Nitoi <florin.nitoi@gmail.com>", | ||
"main": "typemoq.js", | ||
"typings": "typemoq.node.d.ts", | ||
"repository": { | ||
@@ -36,2 +37,3 @@ "type": "git", | ||
"gulp-concat-sourcemap": "^1.3.1", | ||
"gulp-delete-lines": "^0.0.7", | ||
"gulp-filter": "^0.4.1", | ||
@@ -42,2 +44,3 @@ "gulp-if": "^1.2.5", | ||
"gulp-load-plugins": "^0.5.0", | ||
"gulp-mocha": "^2.2.0", | ||
"gulp-rename": "^1.2.0", | ||
@@ -44,0 +47,0 @@ "gulp-size": "^0.3.0", |
228
README.md
@@ -19,2 +19,3 @@ TypeMoq [![build badge](https://travis-ci.org/florinn/typemoq.svg?branch=master)](https://travis-ci.org/florinn/typemoq) | ||
* Auto sandboxing for global classes and objects | ||
* Supports both browser and node.js runtimes | ||
@@ -24,2 +25,4 @@ | ||
------------- | ||
**To be able to use TypeMoq, your project should target ECMAScript 5 or above** | ||
``` | ||
@@ -29,7 +32,35 @@ npm install typemoq | ||
Or if you use Bower: | ||
``` | ||
bower install typemoq | ||
``` | ||
Or add this NuGet dependency to your project: | ||
``` | ||
PM> Install-Package typemoq | ||
``` | ||
The distribution directory should contain: | ||
* **Compiled JavaScript:** `typemoq.js` and its minified version `typemoq-min.js` | ||
* **TypeScript definitions:** `typemoq.d.ts` and `typemoq.node.d.ts` | ||
* *Compiled JavaScript:* `typemoq.js` and its minified version `typemoq-min.js` | ||
* *TypeScript definitions:* `typemoq.d.ts` and `typemoq.node.d.ts` | ||
###### Browser runtime | ||
You need to include in your script file: | ||
```typescript | ||
/// <reference path="./node_modules/typemoq/typemoq.d.ts" /> | ||
``` | ||
TypeMoq requires Underscore to run, so make sure to include it in your page along `typemoq.js`: | ||
```html | ||
<script src="./node_modules/typemoq/node_modules/underscore/underscore.js"></script> | ||
<script src="./node_modules/typemoq/typemoq.js"></script> | ||
``` | ||
After including `typemoq.js` in your page, you should have access to a global variable named `typemoq` | ||
###### Node.js runtime | ||
`typemoq.node.d.ts` declares an external module to use in node.js (commonjs) projects: | ||
@@ -40,6 +71,6 @@ | ||
import tq = require("typemoq"); | ||
import typemoq = require("typemoq"); | ||
``` | ||
**Note:** To be able to use TypeMoq, your project should target **ECMAScript 5** or above | ||
>**Note:** To import TypeMoq in your node.js project when using TypeScript 1.6 or above, you can omit the triple-slash reference line | ||
@@ -50,4 +81,17 @@ | ||
### Create mocks | ||
After importing TypeMoq into your project, the following types should be available: | ||
Type | Description | ||
---- | ---- | ||
*Mock* | Used for creating 'regular' mocks (see [Create mocks](#create_mocks) and [Setup mocks](#setup_mocks)) | ||
*MockBehavior* | Used to specify how the mock should act when no expectations are defined (see [Control mock behavior](#mock_behavior)) | ||
*It* | Helper for matching arguments (see [Setup mocks](#setup_mocks) and [Verify expectations](#verify_expectations)) | ||
*Times* | Helper for performing verification (see [Verify expectations](#verify_expectations)) | ||
*GlobalMock* | Used to create 'global' mocks corresponding to global objects (see [Create global mocks](#create_global_mocks)) | ||
*GlobalScope* | Used to create an execution context that makes use of any specified 'global' mocks (see [Auto sandbox global mocks](#auto_sandbox)) | ||
*MockException* | Exception thrown internally containing debug info | ||
###<a name="create_mocks"></a> Create mocks | ||
Mocks can be created either from class types and constructor arguments or from existing objects, including function objects. | ||
@@ -59,16 +103,18 @@ | ||
// Using class as constructor parameter | ||
var mock: Mock<Bar> = Mock.ofType(Bar); | ||
var mock: TypeMoq.Mock<Bar> = typemoq.Mock.ofType(Bar); | ||
// Using class as constructor parameter and casting result to interface | ||
var mock: TypeMoq.Mock<IBar> = typemoq.Mock.ofType(Bar); | ||
// Using interface as type variable and class as constructor parameter | ||
var mock: Mock<IBar> = Mock.ofType<IBar>(Bar); | ||
var mock: TypeMoq.Mock<IBar> = typemoq.Mock.ofType<IBar>(Bar); | ||
// Using class as constructor parameter and args | ||
var bar = new Bar(); | ||
var mock: Mock<Foo> = Mock.ofType(Foo, MockBehavior.Loose, bar); | ||
var mock: TypeMoq.Mock<Foo> = typemoq.Mock.ofType(Foo, typemoq.MockBehavior.Loose, bar); | ||
// Using a generic class as constructor parameter and args | ||
var mock: Mock<GenericFoo<Bar>> = Mock.ofType(GenericFoo, MockBehavior.Loose, Bar); | ||
var mock: TypeMoq.Mock<GenericFoo<Bar>> = typemoq.Mock.ofType(GenericFoo, typemoq.MockBehavior.Loose, Bar); | ||
``` | ||
>**Note:** `MockBehavior` is used to specify how the mock should act when expectations are not defined, more details in the [Control mock behavior](#mock_behavior) section | ||
@@ -80,16 +126,15 @@ ###### Using existing objects, including function objects | ||
var bar = new Bar(); | ||
var mock: Mock<Bar> = Mock.ofInstance(bar); | ||
var mock: TypeMoq.Mock<Bar> = typemoq.Mock.ofInstance(bar); | ||
// Or from function objects | ||
var mock1: Mock<() => string> = Mock.ofInstance(someFunc); | ||
var mock2: Mock<(a: any, b: any, c: any)=>string> = Mock.ofInstance(someFuncWithArgs); | ||
var mock1: TypeMoq.Mock<() => string> = typemoq.Mock.ofInstance(someFunc); | ||
var mock2: TypeMoq.Mock<(a: any, b: any, c: any)=>string> = typemoq.Mock.ofInstance(someFuncWithArgs); | ||
``` | ||
---------- | ||
**Note:** | ||
Mocks (created in any of the ways listed above) expose the actual mock object through the `.object` property (that has the same type as the class or object being mocked). | ||
**Note:** Mocks (created in any of the ways listed above) expose the actual mock object through the `.object` property (that has the same type as the class or object being mocked). | ||
###<a name="setup_mocks"></a> Setup mocks | ||
### Setup mocks | ||
Mocks allow to match functions, methods and properties and setup return callbacks or exceptions to throw. | ||
@@ -101,8 +146,8 @@ | ||
// Match a no args function | ||
var mock: Mock<() => string> = Mock.ofInstance(someFunc); | ||
var mock: TypeMoq.Mock<() => string> = typemoq.Mock.ofInstance(someFunc); | ||
mock.setup(x => x()).returns(() => "At vero eos et accusamus"); | ||
// Match a function with args | ||
var mock: Mock<(a: any, b: any, c: any) => string> = Mock.ofInstance(someFuncWithArgs); | ||
mock.setup(x => x(It.isAny(), It.isAny(), It.isAny())).returns(() => "At vero eos et accusamus"); | ||
var mock: TypeMoq.Mock<(a: any, b: any, c: any) => string> = typemoq.Mock.ofInstance(someFuncWithArgs); | ||
mock.setup(x => x(typemoq.It.isAny(), typemoq.It.isAny(), typemoq.It.isAny())).returns(() => "At vero eos et accusamus"); | ||
``` | ||
@@ -113,3 +158,3 @@ | ||
```typescript | ||
var mock = Mock.ofType(Doer); | ||
var mock = typemoq.Mock.ofType(Doer); | ||
@@ -120,3 +165,3 @@ // Match a no args method | ||
// Match a method with explicit number value params | ||
mock.setup(x => x.doNumber(It.isValue(321))); | ||
mock.setup(x => x.doNumber(typemoq.It.isValue(321))); | ||
@@ -127,3 +172,3 @@ // Match a method with implicit number value params | ||
// Match a method with explicit string value params | ||
mock.setup(x => x.doString(It.isValue("abc"))); | ||
mock.setup(x => x.doString(typemoq.It.isValue("abc"))); | ||
@@ -135,9 +180,9 @@ // Match a method with implicit string value params | ||
var bar = new Bar(); | ||
mock.setup(x => x.doObject(It.isAnyObject(Bar))); | ||
mock.setup(x => x.doObject(typemoq.It.isAnyObject(Bar))); | ||
// Match a method with any string params | ||
mock.setup(x => x.doString(It.isAnyString())); | ||
mock.setup(x => x.doString(typemoq.It.isAnyString())); | ||
// Match a method with any number params | ||
mock.setup(x => x.doNumber(It.isAnyNumber())); | ||
mock.setup(x => x.doNumber(typemoq.It.isAnyNumber())); | ||
@@ -147,3 +192,3 @@ // Match a method with any interface/class params | ||
var bar2 = new Bar(); | ||
mock.setup(x => x.doBar(It.isAnyObject(Bar))); | ||
mock.setup(x => x.doBar(typemoq.It.isAnyObject(Bar))); | ||
``` | ||
@@ -155,3 +200,3 @@ | ||
// match a property getter | ||
var mock = Mock.ofType(FooWithPublicGetterAndSetter); | ||
var mock = typemoq.Mock.ofType(FooWithPublicGetterAndSetter); | ||
mock.setup(x => x.foo); | ||
@@ -181,12 +226,12 @@ ``` | ||
```typescript | ||
var mock = Mock.ofType(Doer); | ||
var mock = typemoq.Mock.ofType(Doer); | ||
var called1, called2 = false; | ||
var numberArg: number; | ||
mock.setup(x => x.doString(It.isAnyString())).callback(() => called1 = true).returns(s => s.toUpperCase()); | ||
mock.setup(x => x.doNumber(It.isAnyNumber())).callback(n => { numberArg = n; called2 = true; }).returns(n => n + 1); | ||
mock.setup(x => x.doString(typemoq.It.isAnyString())).callback(() => called1 = true).returns(s => s.toUpperCase()); | ||
mock.setup(x => x.doNumber(typemoq.It.isAnyNumber())).callback(n => { numberArg = n; called2 = true; }).returns(n => n + 1); | ||
``` | ||
###<a name="mock_behavior"></a>Control mock behavior | ||
###<a name="mock_behavior"></a> Control mock behavior | ||
@@ -201,3 +246,3 @@ ###### Using MockBehavior | ||
```typescript | ||
var mock = Mock.ofType(Doer, MockBehavior.Strict); | ||
var mock = typemoq.Mock.ofType(Doer, typemoq.MockBehavior.Strict); | ||
``` | ||
@@ -215,3 +260,3 @@ | ||
### Verify expectations | ||
###<a name="verify_expectations"></a> Verify expectations | ||
@@ -224,39 +269,40 @@ Expectations can be verified either one by one or all at once by marking matchers as verifiable. | ||
// Verify that a no args function was called at least once | ||
var mock: Mock<() => string> = Mock.ofInstance(someFunc); | ||
var mock: TypeMoq.Mock<() => string> = typemoq.Mock.ofInstance(someFunc); | ||
mock.object(); | ||
mock.verify(x => x(), Times.atLeastOnce()); | ||
mock.verify(x => x(), typemoq.Times.atLeastOnce()); | ||
// Verify that a function with args was called at least once | ||
var mock: Mock<(a: any, b: any, c: any) => string> = Mock.ofInstance(someFuncWithArgs); | ||
var mock: TypeMoq.Mock<(a: any, b: any, c: any) => string> = typemoq.Mock.ofInstance(someFuncWithArgs); | ||
mock.object(1, 2, 3); | ||
mock.verify(x => x(It.isAnyNumber(), It.isAnyNumber(), It.isAnyNumber()), Times.atLeastOnce()); | ||
mock.verify(x => x(typemoq.It.isAnyNumber(), typemoq.It.isAnyNumber(), typemoq.It.isAnyNumber()), typemoq.Times.atLeastOnce()); | ||
// Verify that no args method was called at least once | ||
var mock = Mock.ofType(Doer); | ||
var mock = typemoq.Mock.ofType(Doer); | ||
mock.object.doVoid(); | ||
mock.verify(x => x.doVoid(), Times.atLeastOnce()); | ||
mock.verify(x => x.doVoid(), typemoq.Times.atLeastOnce()); | ||
// Verify that method with params was called at least once | ||
var mock = Mock.ofType(Doer); | ||
var mock = typemoq.Mock.ofType(Doer); | ||
mock.object.doString("Lorem ipsum dolor sit amet"); | ||
mock.verify(x => x.doString(It.isValue("Lorem ipsum dolor sit amet")), Times.atLeastOnce()); | ||
mock.verify(x => x.doString(typemoq.It.isValue("Lorem ipsum dolor sit amet")), typemoq.Times.atLeastOnce()); | ||
// Verify that value getter was called at least once | ||
var mock = Mock.ofType(Bar); | ||
var mock = typemoq.Mock.ofType(Bar); | ||
mock.object.value; | ||
mock.verify(x => x.value, Times.atLeastOnce()); | ||
mock.verify(x => x.value, typemoq.Times.atLeastOnce()); | ||
// Verify that value setter was called at least once | ||
var mock = Mock.ofType(Bar); | ||
var mock = typemoq.Mock.ofType(Bar); | ||
mock.object.value = "Lorem ipsum dolor sit amet"; | ||
mock.verify(x => x.value = It.isValue("Lorem ipsum dolor sit amet"), Times.atLeastOnce()); | ||
mock.verify(x => x.value = typemoq.It.isValue("Lorem ipsum dolor sit amet"), typemoq.Times.atLeastOnce()); | ||
``` | ||
Varius expectation could be specified by using `Times` constructor methods. | ||
Various expectations can be specified using the `Times` constructor methods. | ||
**Note:** When constructing a mock it is allowed to pass mock objects as arguments and later verify expectations on them. E.g.: | ||
**Note:** | ||
When constructing a mock it is allowed to pass mock objects as arguments and later verify expectations on them. E.g.: | ||
```typescript | ||
var mockBar = Mock.ofType(Bar); | ||
var mockFoo = Mock.ofType(Foo, MockBehavior.Loose, mockBar.object); | ||
var mockBar = typemoq.Mock.ofType(Bar); | ||
var mockFoo = typemoq.Mock.ofType(Foo, typemoq.MockBehavior.Loose, mockBar.object); | ||
mockFoo.callBase = true; | ||
@@ -266,3 +312,3 @@ | ||
mockBar.verify(x => x.value = It.isValue("Lorem ipsum dolor sit amet"), Times.atLeastOnce()); | ||
mockBar.verify(x => x.value = typemoq.It.isValue("Lorem ipsum dolor sit amet"), typemoq.Times.atLeastOnce()); | ||
``` | ||
@@ -273,6 +319,6 @@ | ||
```typescript | ||
var mock = Mock.ofType(Doer); | ||
var mock = typemoq.Mock.ofType(Doer); | ||
mock.setup(x => x.doNumber(999)).verifiable(); | ||
mock.setup(x => x.doString(It.isAny())).verifiable(); | ||
mock.setup(x => x.doString(typemoq.It.isAny())).verifiable(); | ||
mock.setup(x => x.doVoid()).verifiable(); | ||
@@ -288,6 +334,13 @@ | ||
### Create global mocks | ||
###<a name="create_global_mocks"></a> Create global mocks | ||
Global mocks are created by specifying a class type or an existing object, similar to regular mocks, and a container object of the type/object being mocked. | ||
Global mocks are created by specifying a class type or an existing object, similar to regular mocks. | ||
When creating mock instances out of browser global objects (such as `window.localStorage`) you should provide the name of the object ("localStorage" in this case) as the second parameter. | ||
You may also specify a container object for the type/object being mocked as the third parameter. | ||
In browser the top global object is the `window` object, which is considered the default `container` in TypeMoq.GlobalMock. | ||
In node.js the top global object is the `global` object. | ||
###### Using class types | ||
@@ -297,9 +350,12 @@ | ||
// Create an instance using class as ctor parameter | ||
var mock: GlobalMock<GlobalBar> = GlobalMock.ofType(GlobalBar); | ||
var mock: TypeMoq.GlobalMock<GlobalBar> = typemoq.GlobalMock.ofType(GlobalBar, null, window); | ||
// Create an instance using class as ctor parameter and casting result to interface | ||
var mock: TypeMoq.GlobalMock<IGlobalBar> = typemoq.GlobalMock.ofType(GlobalBar, null, window); | ||
// Create an instance using interface as type variable and class as ctor parameter | ||
var mock: GlobalMock<IGlobalBar> = GlobalMock.ofType<IGlobalBar>(GlobalBar); | ||
var mock: TypeMoq.GlobalMock<IGlobalBar> = typemoq.GlobalMock.ofType<IGlobalBar>(GlobalBar, null, window); | ||
// Create an instance of window.XmlHttpRequest global type | ||
var mock = GlobalMock.ofType(XMLHttpRequest); | ||
// Create an instance of 'XmlHttpRequest' global type | ||
var mock = typemoq.GlobalMock.ofType(XMLHttpRequest, null, window); | ||
``` | ||
@@ -313,29 +369,26 @@ | ||
var foo = new Foo(bar); | ||
var mock: GlobalMock<Foo> = GlobalMock.ofInstance(foo); | ||
var mock: TypeMoq.GlobalMock<Foo> = typemoq.GlobalMock.ofInstance(foo); | ||
// Create an instance using a generic class as ctor parameter and ctor args | ||
var foo = new GenericFoo(Bar); | ||
var mock: GlobalMock<GenericFoo<Bar>> = GlobalMock.ofInstance(foo); | ||
var mock: TypeMoq.GlobalMock<GenericFoo<Bar>> = typemoq.GlobalMock.ofInstance(foo); | ||
// Create an instance from an existing object | ||
var bar = new GlobalBar(); | ||
var mock: GlobalMock<GlobalBar> = GlobalMock.ofInstance(bar); | ||
var mock: TypeMoq.GlobalMock<GlobalBar> = typemoq.GlobalMock.ofInstance(bar); | ||
// Create an instance from a function object | ||
var mock1: GlobalMock<() => string> = GlobalMock.ofInstance(someGlobalFunc); | ||
var mock2: GlobalMock<(a: any, b: any, c: any) => string> = GlobalMock.ofInstance(someGlobalFuncWithArgs); | ||
var mock1: TypeMoq.GlobalMock<() => string> = typemoq.GlobalMock.ofInstance(someGlobalFunc); | ||
var mock2: TypeMoq.GlobalMock<(a: any, b: any, c: any) => string> = typemoq.GlobalMock.ofInstance(someGlobalFuncWithArgs); | ||
// Create an instance from window.localStorage global object | ||
var mock = GlobalMock.ofInstance(localStorage, "localStorage"); | ||
// Create an instance from 'window.localStorage' global object | ||
var mock = typemoq.GlobalMock.ofInstance(localStorage, "localStorage"); | ||
``` | ||
**Note:** | ||
Due to browser security limitations, global mocks created by specifying class type cannot have constructor arguments | ||
- Default `container` is considered to be the `window` object | ||
- Due to browser security limitations, global mocks created by specifying class type cannot have constructor arguments | ||
- When creating mock instances out of browser global objects (such as `window.localStorage`) you should provide the name of the object ("localStorage" in this case) | ||
###<a name="auto_sandbox"></a> Auto sandbox global mocks | ||
### Auto sandbox global mocks | ||
Replacing and restoring global class types and objects is done automagically by combining global mocks with global scopes. | ||
@@ -345,4 +398,4 @@ | ||
// Global no args function is auto sandboxed | ||
var mock = GlobalMock.ofInstance(someGlobalFunc); | ||
GlobalScope.using(mock).with(() => { | ||
var mock = typemoq.GlobalMock.ofInstance(someGlobalFunc); | ||
typemoq.GlobalScope.using(mock).with(() => { | ||
someGlobalFunc(); | ||
@@ -353,4 +406,4 @@ someGlobalFunc(); | ||
// Global function with args is auto sandboxed | ||
var mock = GlobalMock.ofInstance(someGlobalFuncWithArgs); | ||
GlobalScope.using(mock).with(() => { | ||
var mock = typemoq.GlobalMock.ofInstance(someGlobalFuncWithArgs); | ||
typemoq.GlobalScope.using(mock).with(() => { | ||
someGlobalFuncWithArgs(1,2,3); | ||
@@ -362,4 +415,4 @@ someGlobalFuncWithArgs("1","2","3"); | ||
// Global object is auto sandboxed | ||
var mock = GlobalMock.ofType(GlobalBar); | ||
GlobalScope.using(mock).with(() => { | ||
var mock = typemoq.GlobalMock.ofType(GlobalBar); | ||
typemoq.GlobalScope.using(mock).with(() => { | ||
var bar1 = new GlobalBar(); | ||
@@ -370,9 +423,9 @@ bar1.value; | ||
// window.XmlHttpRequest global object is auto sandboxed | ||
var mock = GlobalMock.ofType(XMLHttpRequest); | ||
GlobalScope.using(mock).with(() => { | ||
// 'window.XmlHttpRequest' global object is auto sandboxed | ||
var mock = typemoq.GlobalMock.ofType(XMLHttpRequest); | ||
typemoq.GlobalScope.using(mock).with(() => { | ||
var xhr1 = new XMLHttpRequest(); | ||
xhr1.open("GET", "http://www.typescriptlang.org", true); | ||
xhr1.send(); | ||
mock.verify(x => x.send(), Times.exactly(1)); | ||
mock.verify(x => x.send(), typemoq.Times.exactly(1)); | ||
}); | ||
@@ -382,8 +435,8 @@ var xhr2 = new XMLHttpRequest(); | ||
xhr2.send(); | ||
mock.verify(x => x.send(), Times.exactly(1)); | ||
mock.verify(x => x.send(), typemoq.Times.exactly(1)); | ||
// window.localStorage global object is auto sandboxed | ||
var mock = GlobalMock.ofInstance(localStorage, "localStorage"); | ||
mock.setup(x => x.getItem(It.isAnyString())).returns((key: string) => "[]"); | ||
GlobalScope.using(mock).with(() => { | ||
// 'window.localStorage' global object is auto sandboxed | ||
var mock = typemoq.GlobalMock.ofInstance(localStorage, "localStorage"); | ||
mock.setup(x => x.getItem(typemoq.It.isAnyString())).returns((key: string) => "[]"); | ||
typemoq.GlobalScope.using(mock).with(() => { | ||
expect(localStorage.getItem("xyz")).to.eq("[]"); | ||
@@ -395,2 +448,3 @@ }); | ||
**Note:** Within a mock scope when constructing objects from global functions/class types which are being replaced by mocks, the constructor always returns the mocked object (of corresponding type) passed in as argument to the `using` function | ||
**Note:** | ||
Within a mock scope when constructing objects from global functions/class types which are being replaced by mocks, the constructor always returns the mocked object (of corresponding type) passed in as argument to the `using` function |
@@ -1,1 +0,1 @@ | ||
var TypeMoq;!function(e){var t=function(){function e(){}return e.IMATCH_ID_VALUE="438A51D3-6864-49D7-A655-CA1153B86965",e.IMATCH_ID_NAME="___id",e.IMATCH_MATCHES_NAME="___matches",e}();e.Cons=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e}();e.CurrentInterceptContext=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){!function(e){e[e.Class=0]="Class",e[e.Function=1]="Function",e[e.Value=2]="Value"}(e.GlobalType||(e.GlobalType={}));var t=(e.GlobalType,function(){function t(e,t,n,r){this.mock=e,this._name=t,this._type=n,this.container=r}return t.ofInstance=function(n,r,o,i){void 0===o&&(o=window),void 0===i&&(i=0);var c=e.Mock.ofInstance(n,i),a=_.isFunction(n)?1:2;return new t(c,r,a,o)},t.ofType=function(n,r,o){void 0===r&&(r=window),void 0===o&&(o=0);var i=new n,c=e.Mock.ofInstance(i,o);return new t(c,name,0,r)},Object.defineProperty(t.prototype,"object",{get:function(){return this.mock.object},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name||this.mock.name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"behavior",{get:function(){return this.mock.behavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"callBase",{get:function(){return this.mock.callBase},set:function(e){this.mock.callBase=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),t.prototype.setup=function(e){return this.mock.setup(e)},t.prototype.verify=function(e,t){this.mock.verify(e,t)},t.prototype.verifyAll=function(){this.mock.verifyAll()},t}());e.GlobalMock=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e.getOwnEnumerables=function(e){return this._getPropertyNames(e,!0,!1,this._enumerable)},e.getOwnNonenumerables=function(e){return this._getPropertyNames(e,!0,!1,this._notEnumerable)},e.getOwnEnumerablesAndNonenumerables=function(e){return this._getPropertyNames(e,!0,!1,this._enumerableAndNotEnumerable)},e.getPrototypeEnumerables=function(e){return this._getPropertyNames(e,!1,!0,this._enumerable)},e.getPrototypeNonenumerables=function(e){return this._getPropertyNames(e,!1,!0,this._notEnumerable)},e.getPrototypeEnumerablesAndNonenumerables=function(e){return this._getPropertyNames(e,!1,!0,this._enumerableAndNotEnumerable)},e.getOwnAndPrototypeEnumerables=function(e){return this._getPropertyNames(e,!0,!0,this._enumerable)},e.getOwnAndPrototypeNonenumerables=function(e){return this._getPropertyNames(e,!0,!0,this._notEnumerable)},e.getOwnAndPrototypeEnumerablesAndNonenumerables=function(e){return this._getPropertyNames(e,!0,!0,this._enumerableAndNotEnumerable)},e._enumerable=function(e,t){return e.propertyIsEnumerable(t)},e._notEnumerable=function(e,t){return!e.propertyIsEnumerable(t)},e._enumerableAndNotEnumerable=function(){return!0},e._getPropertyNames=function(e,t,n,r){var o=[];do{if(t){var i=Object.getOwnPropertyNames(e);_.forEach(i,function(t){var n=_.find(o,function(e){return e.name===t});if(!n&&r(e,t)){var i=Object.getOwnPropertyDescriptor(e,t);o.push({name:t,desc:i})}})}if(!n)break;t=!0}while(e=Object.getPrototypeOf(e));return o},e}();e.PropertyRetriever=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e.getUUID=function(){var e=(new Date).getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)});return t},e.functionName=function(e){var t=e.toString();return t=t.substr("function ".length),t=t.substr(0,t.indexOf("("))},e.conthunktor=function(e,t){return function(){var n,r,o=function(){};return o.prototype=e.prototype,n=new o,_.isFunction(e)&&(r=e.apply(n,t)),_.isObject(r)?r:n}()},e}();e.Utils=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(e){var t=function(){function e(e,t){this.name=e,this.message=t}return e.prototype.toString=function(){return name},e}();e.Exception=t}(t=e.Error||(e.Error={}))}(TypeMoq||(TypeMoq={}));var __extends=this.__extends||function(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);n.prototype=t.prototype,e.prototype=new n},TypeMoq;!function(e){var t;!function(e){!function(e){e[e.NoSetup=0]="NoSetup",e[e.MoreThanOneSetupExpression=1]="MoreThanOneSetupExpression",e[e.InvalidSetupExpression=2]="InvalidSetupExpression",e[e.InvalidMatcher=3]="InvalidMatcher",e[e.InvalidProxyArgument=4]="InvalidProxyArgument",e[e.UnknownGlobalType=5]="UnknownGlobalType",e[e.VerificationFailed=6]="VerificationFailed",e[e.MoreThanOneCall=7]="MoreThanOneCall",e[e.MoreThanNCalls=8]="MoreThanNCalls"}(e.MockExceptionReason||(e.MockExceptionReason={}));var t=(e.MockExceptionReason,function(e){function t(t,n,r,o){void 0===r&&(r="Mock Exception"),e.call(this,r,o),this.reason=t,this.ctx=n}return __extends(t,e),t}(e.Exception));e.MockException=t}(t=e.Error||(e.Error={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(t){var n=function(){function t(t){this._ctor=t,this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return this._ctor.prototype===e.constructor.prototype&&(t=!0),t},t}();t.MatchAnyObject=n;var r=function(){function t(){this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isUndefined(e)||(t=!0),t},t}();t.MatchAny=r;var o=function(){function t(){this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isString(e)&&(t=!0),t},t}();t.MatchAnyString=o;var i=function(){function t(){this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isNumber(e)&&(t=!0),t},t}();t.MatchAnyNumber=i}(t=e.Match||(e.Match={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(t){var n=function(){function t(t){this._value=t,this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isEqual(this._value,e)&&(t=!0),t},t}();t.MatchValue=n}(t=e.Match||(e.Match={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(e){var t=function(){function e(e,t){this._property=e,this._args=t}return Object.defineProperty(e.prototype,"args",{get:function(){return this._args||{length:0,callee:null}},set:function(e){this._args=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this.returnValue=this._property.toFunc.apply(this._property.obj,this._args)},e}();e.MethodInvocation=t;var n=function(){function e(e,t){this._property=e,this.returnValue=t}return Object.defineProperty(e.prototype,"args",{get:function(){var e=[];return Object.defineProperty(e,"callee",{configurable:!1,enumerable:!0,writable:!1,value:null}),e},set:function(){},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){},e}();e.GetterInvocation=n;var r=function(){function e(e,t){this._property=e,this._args=t}return Object.defineProperty(e.prototype,"args",{get:function(){return this._args},set:function(e){this._args=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this.returnValue=this._property.obj[this._property.name]=this._args[0]},e}();e.SetterInvocation=r;var o=function(){function e(e,t){this.obj=e,this.name=t}return Object.defineProperty(e.prototype,"toFunc",{get:function(){var e;return e=_.isFunction(this.obj)?this.obj:this.obj[this.name]},enumerable:!0,configurable:!0}),e}();e.MethodInfo=o;var i=function(){function e(e,t){this.obj=e,this.name=t}return e}();e.PropertyInfo=i}(t=e.Proxy||(e.Proxy={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(t){var n=function(){function n(t,n){var r=this;this.check(n);var o=this,i=e.PropertyRetriever.getOwnAndPrototypeEnumerablesAndNonenumerables(n);_.each(i,function(e){if(_.isFunction(e.desc.value)){var i={configurable:e.desc.configurable,enumerable:e.desc.enumerable,writable:e.desc.writable};r.defineMethodProxy(o,t,n,e.name,i)}else{var i={configurable:e.desc.configurable,enumerable:e.desc.enumerable};r.definePropertyProxy(o,t,n,e.name,e.desc.value,i)}})}return n.of=function(t,r){n.check(t);var o;if(_.isFunction(t)){var i=e.Utils.functionName(t);o=n.methodProxyValue(r,t,i)}else o=new n(r,t);return o},n.check=function(e){n.checkNotNull(e);var t=!1;if((_.isFunction(e)||_.isObject(e)&&!n.isPrimitiveObject(e))&&(t=!0),!t)throw new error.MockException(4,e,"InvalidProxyArgument Exception","Argument should be a function or a non primitive object")},n.prototype.check=function(e){n.checkNotNull(e);var t=!1;if(_.isFunction(e)||!_.isObject(e)||n.isPrimitiveObject(e)||(t=!0),!t)throw new error.MockException(4,e,"InvalidProxyArgument Exception","Argument should be a non primitive object")},n.checkNotNull=function(e){if(_.isNull(e))throw new error.MockException(4,e,"InvalidProxyArgument Exception","Argument cannot be null")},n.isPrimitiveObject=function(e){var t=!1;return(_.isFunction(e)||_.isArray(e)||_.isDate(e)||_.isNull(e))&&(t=!0),t},n.prototype.defineMethodProxy=function(e,t,r,o,i){void 0===i&&(i={configurable:!1,enumerable:!0,writable:!1}),i.value=n.methodProxyValue(t,r,o),this.defineProperty(e,o,i)},n.methodProxyValue=function(e,n,r){return function(){var o=new t.MethodInfo(n,r),i=new t.MethodInvocation(o,arguments);return e.intercept(i),i.returnValue}},n.prototype.definePropertyProxy=function(e,n,r,o,i,c){void 0===c&&(c={configurable:!1,enumerable:!0}),c.get=function(){var e=new t.PropertyInfo(r,o),c=new t.GetterInvocation(e,i);return n.intercept(c),c.returnValue},c.set=function(){var e=new t.PropertyInfo(r,o),i=new t.SetterInvocation(e,arguments);n.intercept(i)},this.defineProperty(e,o,c)},n.prototype.defineProperty=function(e,t,n){try{Object.defineProperty(e,t,n)}catch(r){console.log(r.message)}},n}();t.Proxy=n}(t=e.Proxy||(e.Proxy={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(e){var t=function(){function t(){}return t.prototype.createProxy=function(t,n){var r=e.Proxy.of(n,t);return r},t}();e.ProxyFactory=t}(t=e.Proxy||(e.Proxy={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){!function(e){e[e.Continue=0]="Continue",e[e.Stop=1]="Stop"}(e.InterceptionAction||(e.InterceptionAction={}));var t=(e.InterceptionAction,function(){function e(e,t){this.behavior=e,this.mock=t,this._actualInvocations=[],this._orderedCalls=[]}return e.prototype.addInvocation=function(e){this._actualInvocations.push(e)},e.prototype.actualInvocations=function(){return this._actualInvocations},e.prototype.clearInvocations=function(){this._actualInvocations=[]},e.prototype.addOrderedCall=function(e){this._orderedCalls.push(e)},e.prototype.removeOrderedCall=function(e){_.filter(this._orderedCalls,function(t){return t.id!==e.id})},e.prototype.orderedCalls=function(){return this._orderedCalls},e}());e.InterceptorContext=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function t(t,n){this._interceptorContext=new e.InterceptorContext(t,n)}return Object.defineProperty(t.prototype,"interceptorContext",{get:function(){return this._interceptorContext},enumerable:!0,configurable:!0}),t.prototype.intercept=function(t){var n=this,r=new e.CurrentInterceptContext;_.some(this.interceptionStrategies(),function(e){return 1===e.handleIntercept(t,n.interceptorContext,r)?!0:void 0})},t.prototype.addCall=function(e){this._interceptorContext.addOrderedCall(e)},t.prototype.verifyCall=function(e,t){var n=this._interceptorContext.actualInvocations(),r=_.filter(n,function(t){return e.matches(t)}).length;t.verify(r)||this.throwVerifyCallException(e.setupCall,t)},t.prototype.verify=function(){var t=this._interceptorContext.orderedCalls(),n=_.filter(t,function(e){return e.isVerifiable}),r=_.filter(t,function(e){return e.isVerifiable&&e.isInvoked}),o=e.Times.exactly(n.length);o.verify(r.length)||this.throwVerifyException(n,o)},t.prototype.interceptionStrategies=function(){var t=[new e.AddActualInvocation,new e.ExtractProxyCall,new e.ExecuteCall,new e.InvokeBase,new e.HandleMockRecursion];return t},t.prototype.throwVerifyCallException=function(e,t){var n=new error.MockException(6,e,"VerifyCall Exception",t.failMessage);throw n},t.prototype.throwVerifyException=function(e,t){var n=new error.MockException(6,e,"Verify Exception",t.failMessage);throw n},t}();e.InterceptorExecute=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return Object.defineProperty(e.prototype,"interceptedCall",{get:function(){return this._interceptedCall},enumerable:!0,configurable:!0}),e.prototype.intercept=function(e){if(this._interceptedCall)throw new error.MockException(1,e,"MoreThanOneSetupExpression Exception","Setup should contain only one expression");this._interceptedCall=e},e}();e.InterceptorSetup=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e.prototype.handleIntercept=function(e,t){return t.addInvocation(e),0},e}();e.AddActualInvocation=t;var n=function(){function e(){}return e.prototype.handleIntercept=function(e,t,n){var r=t.orderedCalls().reverse();if(n.call=_.find(r,function(t){return t.matches(e)}),null!=n.call)n.call.evaluatedSuccessfully();else if(1==t.behavior)throw new error.MockException(0,e);return 0},e}();e.ExtractProxyCall=n;var r=function(){function e(){}return e.prototype.handleIntercept=function(e,t,n){this._ctx=t;var r=n.call;return null!=r?(r.execute(e),1):0},e}();e.ExecuteCall=r;var o=function(){function e(){}return e.prototype.handleIntercept=function(e,t){return t.mock.callBase?(e.invokeBase(),1):0},e}();e.InvokeBase=o;var i=function(){function e(){}return e.prototype.handleIntercept=function(){return 0},e}();e.HandleMockRecursion=i}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e.isValue=function(e){var t=new match.MatchValue(e);return t},e.isAnyObject=function(e){var t=new match.MatchAnyObject(e);return t},e.isAny=function(){var e=new match.MatchAny;return e},e.isAnyString=function(){var e=new match.MatchAnyString;return e},e.isAnyNumber=function(){var e=new match.MatchAnyNumber;return e},e}();e.It=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function t(t,n){this.mock=t,this._setupExpression=n,this._id=this.generateId();var r=new e.InterceptorSetup,o=e.Mock.proxyFactory.createProxy(r,t.instance);if(n(o),!r.interceptedCall)throw new error.MockException(2,this._setupExpression,"InvalidSetupExpression Exception","Invalid setup expression");var i=r.interceptedCall,c=this.transformToMatchers(i.args);Object.defineProperty(c,"callee",{configurable:!1,enumerable:!0,writable:!1,value:i.args.callee}),i.args=c,this._setupCall=i}return t.prototype.generateId=function(){return"MethodCall<"+_.uniqueId()+">"},t.prototype.transformToMatchers=function(t){var n=[];return _.each(t,function(t){if(_.isObject(t)){if(_.isUndefined(t[e.Cons.IMATCH_MATCHES_NAME])||_.isUndefined(t[e.Cons.IMATCH_ID_NAME])||t[e.Cons.IMATCH_ID_NAME]!==e.Cons.IMATCH_ID_VALUE)throw new error.MockException(3,t,"InvalidMatcher Exception","Invalid match object");n.push(t)}else{var r=new match.MatchValue(t);n.push(r)}}),n},Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"callCount",{get:function(){return this._callCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"setupExpression",{get:function(){return this._setupExpression},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"setupCall",{get:function(){return this._setupCall},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isVerifiable",{get:function(){return this._isVerifiable},enumerable:!0,configurable:!0}),t.prototype.evaluatedSuccessfully=function(){this._evaluatedSuccessfully=!0},t.prototype.matches=function(e){var t=!1;return this._setupCall.property&&e&&e.property&&this._setupCall.property.name===e.property.name&&this._setupCall.args.length===e.args.length&&(t=!0,_.each(this.setupCall.args,function(n,r){var o=n,i=e.args[r];t&&!o.___matches(i)&&(t=!1)})),t},t.prototype.execute=function(t){if(this.isInvoked=!0,null!=this._setupCallback&&this._setupCallback.apply(this,t.args),null!=this._thrownException)throw this._thrownException;if(this._callCount++,this._isOnce){var n=e.Times.atMostOnce();if(!n.verify(this._callCount))throw new error.MockException(7,this,"MoreThanOneCall Exception",n.failMessage)}if(this._expectedCallCount){var n=e.Times.exactly(this._expectedCallCount);if(!n.verify(this._callCount))throw new error.MockException(8,this,"MoreThanNCalls Exception",n.failMessage)}},t.prototype.verifiable=function(e){this._isVerifiable=!0,null!=e&&(this.failMessage=e)},t}();e.MethodCall=t}(TypeMoq||(TypeMoq={}));var __extends=this.__extends||function(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);n.prototype=t.prototype,e.prototype=new n},TypeMoq;!function(e){var t=function(e){function t(t,n){e.call(this,t,n)}return __extends(t,e),t.prototype.execute=function(t){e.prototype.execute.call(this,t),this._callBase?t.invokeBase():this.hasReturnValue&&(t.returnValue=this._returnValueFunc.apply(this,t.args))},t.prototype.callback=function(e){return this._setupCallback=e,this},t.prototype["throws"]=function(e){return this._thrownException=e,this},t.prototype.returns=function(e){return this._returnValueFunc=e,this.hasReturnValue=!0,this},t.prototype.callBase=function(){return this._callBase=!0,this},t}(e.MethodCall);e.MethodCallReturn=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){!function(e){e[e.Loose=0]="Loose",e[e.Strict=1]="Strict"}(e.MockBehavior||(e.MockBehavior={}));var t=(e.MockBehavior,function(){function t(n,r){void 0===r&&(r=0),this.instance=n,this._behavior=r,this._id=this.generateId(),this._name=this.getNameOf(n),this._interceptor=new e.InterceptorExecute(this._behavior,this),this._proxy=t.proxyFactory.createProxy(this._interceptor,n)}return t.ofInstance=function(e,n){void 0===n&&(n=0);var r=new t(e,n);return r},t.ofType=function(e,n){void 0===n&&(n=0);for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];var i=t.ofType2(e,r,n);return i},t.ofType2=function(n,r,o){void 0===o&&(o=0);var i=e.Utils.conthunktor(n,r),c=new t(i,o);return c},Object.defineProperty(t.prototype,"object",{get:function(){return this._proxy},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"behavior",{get:function(){return this._behavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"callBase",{get:function(){return this._callBase},set:function(e){this._callBase=e},enumerable:!0,configurable:!0}),t.prototype.generateId=function(){return"Mock<"+_.uniqueId()+">"},t.prototype.getNameOf=function(t){var n;if(_.isFunction(t))n=e.Utils.functionName(t);else if(_.isObject(t)){var r=t.constructor;n=e.Utils.functionName(r)}return n&&(n=n.trim()),n},t.prototype.setup=function(t){var n=new e.MethodCallReturn(this,t);return this._interceptor.addCall(n),n},t.prototype.verify=function(t,n){var r=new e.MethodCall(this,t);this._interceptor.addCall(r);try{this._interceptor.verifyCall(r,n)}catch(o){throw o}},t.prototype.verifyAll=function(){try{this._interceptor.verify()}catch(e){throw e}},t.proxyFactory=new e.Proxy.ProxyFactory,t}());e.Mock=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(e,t,n,r){this._condition=e,this._from=t,this._to=n,this._failMessage=_.template(r)}return Object.defineProperty(e.prototype,"failMessage",{get:function(){return this._failMessage({n:this._from,m:this._lastCallCount})},enumerable:!0,configurable:!0}),e.prototype.verify=function(e){return this._lastCallCount=e,this._condition(e)},e.exactly=function(t){return new e(function(e){return e===t},t,t,e.NO_MATCHING_CALLS_EXACTLY_N_TIMES)},e.never=function(){return e.exactly(0)},e.once=function(){return e.exactly(1)},e.atLeastOnce=function(){return new e(function(e){return e>=1},1,Number.MAX_VALUE,e.NO_MATCHING_CALLS_AT_LEAST_ONCE)},e.atMostOnce=function(){return new e(function(e){return e>=0&&1>=e},0,1,e.NO_MATCHING_CALLS_AT_MOST_ONCE)},e.NO_MATCHING_CALLS_EXACTLY_N_TIMES="Expected invocation on the mock <%= n %> times, invoked <%= m %> times",e.NO_MATCHING_CALLS_AT_LEAST_ONCE="Expected invocation on the mock at least once",e.NO_MATCHING_CALLS_AT_MOST_ONCE="Expected invocation on the mock at most once",e}();e.Times=t}(TypeMoq||(TypeMoq={}));var error=TypeMoq.Error,match=TypeMoq.Match,proxy=TypeMoq.Proxy,TypeMoq;if(function(e){var t=function(){function t(e){this._args=e}return t.using=function(){for(var e=[],n=0;n<arguments.length;n++)e[n-0]=arguments[n];var r=new t(e);return r},t.prototype["with"]=function(t){var n=[];try{_.each(this._args,function(t){if(!_.isUndefined(t.container[t.name])){var r=e.PropertyRetriever.getOwnAndPrototypeEnumerablesAndNonenumerables(t.container),o=_.find(r,function(e){return e.name===t.name});n[t.name]=o.desc;var i={};switch(t.type){case 0:i.value=function(){return t.mock.object};break;case 1:i.value=t.mock.object;break;case 2:i.get=function(){return t.mock.object};break;default:throw new error.MockException(5,t,"UnknownGlobalType Exception","unknown global type: "+t.type)}Object.defineProperty(t.container,t.name,i)}}),t.apply(this,this._args)}finally{_.each(this._args,function(e){if(!_.isUndefined(e.mock.instance)){var t=n[e.name];switch(e.type){case 0:break;case 1:break;case 2:t.configurable=!0}Object.defineProperty(e.container,e.name,t)}})}},t}();e.GlobalScope=t}(TypeMoq||(TypeMoq={})),"undefined"!=typeof require)var _=require("underscore");"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=TypeMoq),exports.TypeMoq=TypeMoq):this.TypeMoq=TypeMoq; | ||
var TypeMoq;!function(e){var t=function(){function e(){}return e.IMATCH_ID_VALUE="438A51D3-6864-49D7-A655-CA1153B86965",e.IMATCH_ID_NAME="___id",e.IMATCH_MATCHES_NAME="___matches",e}();e.Cons=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e}();e.CurrentInterceptContext=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){!function(e){e[e.Class=0]="Class",e[e.Function=1]="Function",e[e.Value=2]="Value"}(e.GlobalType||(e.GlobalType={}));var t=e.GlobalType,n=function(){function n(e,t,n,o){this.mock=e,this._name=t,this._type=n,this.container=o}return n.ofInstance=function(o,r,i,c){void 0===i&&(i=window),void 0===c&&(c=e.MockBehavior.Loose);var a=e.Mock.ofInstance(o,c),u=_.isFunction(o)?t.Function:t.Value;return new n(a,r,u,i)},n.ofType=function(o,r,i,c){void 0===i&&(i=window),void 0===c&&(c=e.MockBehavior.Loose);var a=new o,u=e.Mock.ofInstance(a,c);return new n(u,r,t.Class,i)},Object.defineProperty(n.prototype,"object",{get:function(){return this.mock.object},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name||this.mock.name},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"behavior",{get:function(){return this.mock.behavior},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"callBase",{get:function(){return this.mock.callBase},set:function(e){this.mock.callBase=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),n.prototype.setup=function(e){return this.mock.setup(e)},n.prototype.verify=function(e,t){this.mock.verify(e,t)},n.prototype.verifyAll=function(){this.mock.verifyAll()},n}();e.GlobalMock=n}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e.getOwnEnumerables=function(e){return this._getPropertyNames(e,!0,!1,this._enumerable)},e.getOwnNonenumerables=function(e){return this._getPropertyNames(e,!0,!1,this._notEnumerable)},e.getOwnEnumerablesAndNonenumerables=function(e){return this._getPropertyNames(e,!0,!1,this._enumerableAndNotEnumerable)},e.getPrototypeEnumerables=function(e){return this._getPropertyNames(e,!1,!0,this._enumerable)},e.getPrototypeNonenumerables=function(e){return this._getPropertyNames(e,!1,!0,this._notEnumerable)},e.getPrototypeEnumerablesAndNonenumerables=function(e){return this._getPropertyNames(e,!1,!0,this._enumerableAndNotEnumerable)},e.getOwnAndPrototypeEnumerables=function(e){return this._getPropertyNames(e,!0,!0,this._enumerable)},e.getOwnAndPrototypeNonenumerables=function(e){return this._getPropertyNames(e,!0,!0,this._notEnumerable)},e.getOwnAndPrototypeEnumerablesAndNonenumerables=function(e){return this._getPropertyNames(e,!0,!0,this._enumerableAndNotEnumerable)},e._enumerable=function(e,t){return e.propertyIsEnumerable(t)},e._notEnumerable=function(e,t){return!e.propertyIsEnumerable(t)},e._enumerableAndNotEnumerable=function(e,t){return!0},e._getPropertyNames=function(e,t,n,o){var r=[];do{if(t){var i=Object.getOwnPropertyNames(e);_.forEach(i,function(t){var n=_.find(r,function(e){return e.name===t});if(!n&&o(e,t)){var i=Object.getOwnPropertyDescriptor(e,t);r.push({name:t,desc:i})}})}if(!n)break;t=!0}while(e=Object.getPrototypeOf(e));return r},e}();e.PropertyRetriever=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e.getUUID=function(){var e=(new Date).getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)});return t},e.functionName=function(e){var t=e.toString();return t=t.substr("function ".length),t=t.substr(0,t.indexOf("("))},e.conthunktor=function(e,t){return function(){var n,o,r=function(){};return r.prototype=e.prototype,n=new r,_.isFunction(e)&&(o=e.apply(n,t)),_.isObject(o)?o:n}()},e}();e.Utils=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(e){var t=function(){function e(e,t){this.name=e,this.message=t,this.name=e}return e.prototype.toString=function(){return this.name},e}();e.Exception=t}(t=e.Error||(e.Error={}))}(TypeMoq||(TypeMoq={}));var __extends=this&&this.__extends||function(e,t){function n(){this.constructor=e}for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},TypeMoq;!function(e){var t;!function(e){!function(e){e[e.NoSetup=0]="NoSetup",e[e.MoreThanOneSetupExpression=1]="MoreThanOneSetupExpression",e[e.InvalidSetupExpression=2]="InvalidSetupExpression",e[e.InvalidMatcher=3]="InvalidMatcher",e[e.InvalidProxyArgument=4]="InvalidProxyArgument",e[e.UnknownGlobalType=5]="UnknownGlobalType",e[e.VerificationFailed=6]="VerificationFailed",e[e.MoreThanOneCall=7]="MoreThanOneCall",e[e.MoreThanNCalls=8]="MoreThanNCalls"}(e.MockExceptionReason||(e.MockExceptionReason={}));var t=(e.MockExceptionReason,function(e){function t(t,n,o,r){void 0===o&&(o="Mock Exception"),e.call(this,o,r),this.reason=t,this.ctx=n}return __extends(t,e),t}(e.Exception));e.MockException=t}(t=e.Error||(e.Error={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(t){var n=function(){function t(t){this._ctor=t,this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return this._ctor.prototype===e.constructor.prototype&&(t=!0),t},t}();t.MatchAnyObject=n;var o=function(){function t(){this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isUndefined(e)||(t=!0),t},t}();t.MatchAny=o;var r=function(){function t(){this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isString(e)&&(t=!0),t},t}();t.MatchAnyString=r;var i=function(){function t(){this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isNumber(e)&&(t=!0),t},t}();t.MatchAnyNumber=i}(t=e.Match||(e.Match={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(t){var n=function(){function t(t){this._value=t,this.___id=e.Cons.IMATCH_ID_VALUE}return t.prototype.___matches=function(e){var t=!1;return _.isEqual(this._value,e)&&(t=!0),t},t}();t.MatchValue=n}(t=e.Match||(e.Match={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(e){var t=function(){function e(e,t){this._property=e,this._args=t}return Object.defineProperty(e.prototype,"args",{get:function(){return this._args||{length:0,callee:null}},set:function(e){this._args=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this.returnValue=this._property.toFunc.apply(this._property.obj,this._args)},e}();e.MethodInvocation=t;var n=function(){function e(e,t){this._property=e,this.returnValue=t}return Object.defineProperty(e.prototype,"args",{get:function(){var e=[];return Object.defineProperty(e,"callee",{configurable:!1,enumerable:!0,writable:!1,value:null}),e},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){},e}();e.GetterInvocation=n;var o=function(){function e(e,t){this._property=e,this._args=t}return Object.defineProperty(e.prototype,"args",{get:function(){return this._args},set:function(e){this._args=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this.returnValue=this._property.obj[this._property.name]=this._args[0]},e}();e.SetterInvocation=o;var r=function(){function e(e,t){this.obj=e,this.name=t}return Object.defineProperty(e.prototype,"toFunc",{get:function(){var e;return e=_.isFunction(this.obj)?this.obj:this.obj[this.name]},enumerable:!0,configurable:!0}),e}();e.MethodInfo=r;var i=function(){function e(e,t){this.obj=e,this.name=t}return e}();e.PropertyInfo=i}(t=e.Proxy||(e.Proxy={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(t){var n=function(){function n(t,n){var o=this;this.check(n);var r=this,i=e.PropertyRetriever.getOwnAndPrototypeEnumerablesAndNonenumerables(n);_.each(i,function(e){if(_.isFunction(e.desc.value)){var i={configurable:e.desc.configurable,enumerable:e.desc.enumerable,writable:e.desc.writable};o.defineMethodProxy(r,t,n,e.name,i)}else{var i={configurable:e.desc.configurable,enumerable:e.desc.enumerable};o.definePropertyProxy(r,t,n,e.name,e.desc.value,i)}})}return n.of=function(t,o){n.check(t);var r;if(_.isFunction(t)){var i=e.Utils.functionName(t);r=n.methodProxyValue(o,t,i)}else r=new n(o,t);return r},n.check=function(e){n.checkNotNull(e);var t=!1;if((_.isFunction(e)||_.isObject(e)&&!n.isPrimitiveObject(e))&&(t=!0),!t)throw new error.MockException(error.MockExceptionReason.InvalidProxyArgument,e,"InvalidProxyArgument Exception","Argument should be a function or a non primitive object")},n.prototype.check=function(e){n.checkNotNull(e);var t=!1;if(_.isFunction(e)||!_.isObject(e)||n.isPrimitiveObject(e)||(t=!0),!t)throw new error.MockException(error.MockExceptionReason.InvalidProxyArgument,e,"InvalidProxyArgument Exception","Argument should be a non primitive object")},n.checkNotNull=function(e){if(_.isNull(e))throw new error.MockException(error.MockExceptionReason.InvalidProxyArgument,e,"InvalidProxyArgument Exception","Argument cannot be null")},n.isPrimitiveObject=function(e){var t=!1;return(_.isFunction(e)||_.isArray(e)||_.isDate(e)||_.isNull(e))&&(t=!0),t},n.prototype.defineMethodProxy=function(e,t,o,r,i){void 0===i&&(i={configurable:!1,enumerable:!0,writable:!1}),i.value=n.methodProxyValue(t,o,r),this.defineProperty(e,r,i)},n.methodProxyValue=function(e,n,o){function r(){var r=new t.MethodInfo(n,o),i=new t.MethodInvocation(r,arguments);return e.intercept(i),i.returnValue}return r},n.prototype.definePropertyProxy=function(e,n,o,r,i,c){function a(){var e=new t.PropertyInfo(o,r),c=new t.GetterInvocation(e,i);return n.intercept(c),c.returnValue}function u(e){var i=new t.PropertyInfo(o,r),c=new t.SetterInvocation(i,arguments);n.intercept(c)}void 0===c&&(c={configurable:!1,enumerable:!0}),c.get=a,c.set=u,this.defineProperty(e,r,c)},n.prototype.defineProperty=function(e,t,n){try{Object.defineProperty(e,t,n)}catch(o){console.log(o.message)}},n}();t.Proxy=n}(t=e.Proxy||(e.Proxy={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t;!function(e){var t=function(){function t(){}return t.prototype.createProxy=function(t,n){var o=e.Proxy.of(n,t);return o},t}();e.ProxyFactory=t}(t=e.Proxy||(e.Proxy={}))}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){!function(e){e[e.Continue=0]="Continue",e[e.Stop=1]="Stop"}(e.InterceptionAction||(e.InterceptionAction={}));var t=(e.InterceptionAction,function(){function e(e,t){this.behavior=e,this.mock=t,this._actualInvocations=[],this._orderedCalls=[]}return e.prototype.addInvocation=function(e){this._actualInvocations.push(e)},e.prototype.actualInvocations=function(){return this._actualInvocations},e.prototype.clearInvocations=function(){this._actualInvocations=[]},e.prototype.addOrderedCall=function(e){this._orderedCalls.push(e)},e.prototype.removeOrderedCall=function(e){_.filter(this._orderedCalls,function(t){return t.id!==e.id})},e.prototype.orderedCalls=function(){return this._orderedCalls},e}());e.InterceptorContext=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function t(t,n){this._interceptorContext=new e.InterceptorContext(t,n)}return Object.defineProperty(t.prototype,"interceptorContext",{get:function(){return this._interceptorContext},enumerable:!0,configurable:!0}),t.prototype.intercept=function(t){var n=this,o=new e.CurrentInterceptContext;_.some(this.interceptionStrategies(),function(r){return e.InterceptionAction.Stop===r.handleIntercept(t,n.interceptorContext,o)?!0:void 0})},t.prototype.addCall=function(e){this._interceptorContext.addOrderedCall(e)},t.prototype.verifyCall=function(e,t){var n=this._interceptorContext.actualInvocations(),o=_.filter(n,function(t){return e.matches(t)}).length;t.verify(o)||this.throwVerifyCallException(e.setupCall,t)},t.prototype.verify=function(){var t=this._interceptorContext.orderedCalls(),n=_.filter(t,function(e){return e.isVerifiable}),o=_.filter(t,function(e){return e.isVerifiable&&e.isInvoked}),r=e.Times.exactly(n.length);r.verify(o.length)||this.throwVerifyException(n,r)},t.prototype.interceptionStrategies=function(){var t=[new e.AddActualInvocation,new e.ExtractProxyCall,new e.ExecuteCall,new e.InvokeBase,new e.HandleMockRecursion];return t},t.prototype.throwVerifyCallException=function(e,t){var n=new error.MockException(error.MockExceptionReason.VerificationFailed,e,"VerifyCall Exception",t.failMessage);throw n},t.prototype.throwVerifyException=function(e,t){var n=new error.MockException(error.MockExceptionReason.VerificationFailed,e,"Verify Exception",t.failMessage);throw n},t}();e.InterceptorExecute=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return Object.defineProperty(e.prototype,"interceptedCall",{get:function(){return this._interceptedCall},enumerable:!0,configurable:!0}),e.prototype.intercept=function(e){if(this._interceptedCall)throw new error.MockException(error.MockExceptionReason.MoreThanOneSetupExpression,e,"MoreThanOneSetupExpression Exception","Setup should contain only one expression");this._interceptedCall=e},e}();e.InterceptorSetup=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function t(){}return t.prototype.handleIntercept=function(t,n,o){return n.addInvocation(t),e.InterceptionAction.Continue},t}();e.AddActualInvocation=t;var n=function(){function t(){}return t.prototype.handleIntercept=function(t,n,o){var r=n.orderedCalls().slice().reverse();if(o.call=_.find(r,function(e){return e.matches(t)}),null!=o.call)o.call.evaluatedSuccessfully();else if(n.behavior==e.MockBehavior.Strict)throw new error.MockException(error.MockExceptionReason.NoSetup,t);return e.InterceptionAction.Continue},t}();e.ExtractProxyCall=n;var o=function(){function t(){}return t.prototype.handleIntercept=function(t,n,o){this._ctx=n;var r=o.call;return null!=r?(r.execute(t),e.InterceptionAction.Stop):e.InterceptionAction.Continue},t}();e.ExecuteCall=o;var r=function(){function t(){}return t.prototype.handleIntercept=function(t,n,o){return n.mock.callBase?(t.invokeBase(),e.InterceptionAction.Stop):e.InterceptionAction.Continue},t}();e.InvokeBase=r;var i=function(){function t(){}return t.prototype.handleIntercept=function(t,n,o){return e.InterceptionAction.Continue},t}();e.HandleMockRecursion=i}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(){}return e.isValue=function(e){var t=new match.MatchValue(e);return t},e.isAnyObject=function(e){var t=new match.MatchAnyObject(e);return t},e.isAny=function(){var e=new match.MatchAny;return e},e.isAnyString=function(){var e=new match.MatchAnyString;return e},e.isAnyNumber=function(){var e=new match.MatchAnyNumber;return e},e}();e.It=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function t(t,n){this.mock=t,this._setupExpression=n,this._id=this.generateId();var o=new e.InterceptorSetup,r=e.Mock.proxyFactory.createProxy(o,t.instance);if(n(r),!o.interceptedCall)throw new error.MockException(error.MockExceptionReason.InvalidSetupExpression,this._setupExpression,"InvalidSetupExpression Exception","Invalid setup expression");var i=o.interceptedCall,c=this.transformToMatchers(i.args);Object.defineProperty(c,"callee",{configurable:!1,enumerable:!0,writable:!1,value:i.args.callee}),i.args=c,this._setupCall=i}return t.prototype.generateId=function(){return"MethodCall<"+_.uniqueId()+">"},t.prototype.transformToMatchers=function(t){var n=[];return _.each(t,function(t){if(_.isObject(t)){if(_.isUndefined(t[e.Cons.IMATCH_MATCHES_NAME])||_.isUndefined(t[e.Cons.IMATCH_ID_NAME])||t[e.Cons.IMATCH_ID_NAME]!==e.Cons.IMATCH_ID_VALUE)throw new error.MockException(error.MockExceptionReason.InvalidMatcher,t,"InvalidMatcher Exception","Invalid match object");n.push(t)}else{var o=new match.MatchValue(t);n.push(o)}}),n},Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"callCount",{get:function(){return this._callCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"setupExpression",{get:function(){return this._setupExpression},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"setupCall",{get:function(){return this._setupCall},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isVerifiable",{get:function(){return this._isVerifiable},enumerable:!0,configurable:!0}),t.prototype.evaluatedSuccessfully=function(){this._evaluatedSuccessfully=!0},t.prototype.matches=function(e){var t=!1;return this._setupCall.property&&e&&e.property&&this._setupCall.property.name===e.property.name&&this._setupCall.args.length===e.args.length&&(t=!0,_.each(this.setupCall.args,function(n,o){var r=n,i=e.args[o];t&&!r.___matches(i)&&(t=!1)})),t},t.prototype.execute=function(t){if(this.isInvoked=!0,null!=this._setupCallback&&this._setupCallback.apply(this,t.args),null!=this._thrownException)throw this._thrownException;if(this._callCount++,this._isOnce){var n=e.Times.atMostOnce();if(!n.verify(this._callCount))throw new error.MockException(error.MockExceptionReason.MoreThanOneCall,this,"MoreThanOneCall Exception",n.failMessage)}if(this._expectedCallCount){var n=e.Times.exactly(this._expectedCallCount);if(!n.verify(this._callCount))throw new error.MockException(error.MockExceptionReason.MoreThanNCalls,this,"MoreThanNCalls Exception",n.failMessage)}},t.prototype.verifiable=function(e){this._isVerifiable=!0,null!=e&&(this.failMessage=e)},t}();e.MethodCall=t}(TypeMoq||(TypeMoq={}));var __extends=this&&this.__extends||function(e,t){function n(){this.constructor=e}for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},TypeMoq;!function(e){var t=function(e){function t(t,n){e.call(this,t,n)}return __extends(t,e),t.prototype.execute=function(t){e.prototype.execute.call(this,t),this._callBase?t.invokeBase():this.hasReturnValue&&(t.returnValue=this._returnValueFunc.apply(this,t.args))},t.prototype.callback=function(e){return this._setupCallback=e,this},t.prototype["throws"]=function(e){return this._thrownException=e,this},t.prototype.returns=function(e){return this._returnValueFunc=e,this.hasReturnValue=!0,this},t.prototype.callBase=function(){return this._callBase=!0,this},t}(e.MethodCall);e.MethodCallReturn=t}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){!function(e){e[e.Loose=0]="Loose",e[e.Strict=1]="Strict"}(e.MockBehavior||(e.MockBehavior={}));var t=e.MockBehavior,n=function(){function n(o,r){void 0===r&&(r=t.Loose),this.instance=o,this._behavior=r,this._id=this.generateId(),this._name=this.getNameOf(o),this._interceptor=new e.InterceptorExecute(this._behavior,this),this._proxy=n.proxyFactory.createProxy(this._interceptor,o)}return n.ofInstance=function(e,o){void 0===o&&(o=t.Loose);var r=new n(e,o);return r},n.ofType=function(e,o){void 0===o&&(o=t.Loose);for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var c=n.ofType2(e,r,o);return c},n.ofType2=function(o,r,i){void 0===i&&(i=t.Loose);var c=e.Utils.conthunktor(o,r),a=new n(c,i);return a},Object.defineProperty(n.prototype,"object",{get:function(){return this._proxy},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"behavior",{get:function(){return this._behavior},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"callBase",{get:function(){return this._callBase},set:function(e){this._callBase=e},enumerable:!0,configurable:!0}),n.prototype.generateId=function(){return"Mock<"+_.uniqueId()+">"},n.prototype.getNameOf=function(t){var n;if(_.isFunction(t))n=e.Utils.functionName(t);else if(_.isObject(t)){var o=t.constructor;n=e.Utils.functionName(o)}return n&&(n=n.trim()),n},n.prototype.setup=function(t){var n=new e.MethodCallReturn(this,t);return this._interceptor.addCall(n),n},n.prototype.verify=function(t,n){var o=new e.MethodCall(this,t);this._interceptor.addCall(o);try{this._interceptor.verifyCall(o,n)}catch(r){throw r}},n.prototype.verifyAll=function(){try{this._interceptor.verify()}catch(e){throw e}},n.proxyFactory=new e.Proxy.ProxyFactory,n}();e.Mock=n}(TypeMoq||(TypeMoq={}));var TypeMoq;!function(e){var t=function(){function e(e,t,n,o){this._condition=e,this._from=t,this._to=n,this._failMessage=_.template(o)}return Object.defineProperty(e.prototype,"failMessage",{get:function(){return this._failMessage({n:this._from,m:this._lastCallCount})},enumerable:!0,configurable:!0}),e.prototype.verify=function(e){return this._lastCallCount=e,this._condition(e)},e.exactly=function(t){return new e(function(e){return e===t},t,t,e.NO_MATCHING_CALLS_EXACTLY_N_TIMES)},e.never=function(){return e.exactly(0)},e.once=function(){return e.exactly(1)},e.atLeastOnce=function(){return new e(function(e){return e>=1},1,Number.MAX_VALUE,e.NO_MATCHING_CALLS_AT_LEAST_ONCE)},e.atMostOnce=function(){return new e(function(e){return e>=0&&1>=e},0,1,e.NO_MATCHING_CALLS_AT_MOST_ONCE)},e.NO_MATCHING_CALLS_EXACTLY_N_TIMES="Expected invocation on the mock <%= n %> times, invoked <%= m %> times",e.NO_MATCHING_CALLS_AT_LEAST_ONCE="Expected invocation on the mock at least once",e.NO_MATCHING_CALLS_AT_MOST_ONCE="Expected invocation on the mock at most once",e}();e.Times=t}(TypeMoq||(TypeMoq={}));var error=TypeMoq.Error,match=TypeMoq.Match,proxy=TypeMoq.Proxy,TypeMoq;!function(e){var t=function(){function t(e){this._args=e}return t.using=function(){for(var e=[],n=0;n<arguments.length;n++)e[n-0]=arguments[n];var o=new t(e);return o},t.prototype["with"]=function(t){var n=[];try{_.each(this._args,function(t){if(!_.isUndefined(t.container[t.name])){var o=e.PropertyRetriever.getOwnAndPrototypeEnumerablesAndNonenumerables(t.container),r=_.find(o,function(e){return e.name===t.name});n[t.name]=r.desc;var i={};switch(t.type){case e.GlobalType.Class:i.value=function(){return t.mock.object};break;case e.GlobalType.Function:i.value=t.mock.object;break;case e.GlobalType.Value:i.get=function(){return t.mock.object};break;default:throw new error.MockException(error.MockExceptionReason.UnknownGlobalType,t,"UnknownGlobalType Exception","unknown global type: "+t.type)}try{Object.defineProperty(t.container,t.name,i)}catch(c){console.log("1: "+c)}}}),t.apply(this,this._args)}finally{_.each(this._args,function(t){if(!_.isUndefined(t.mock.instance)){var o=n[t.name];if(o){switch(t.type){case e.GlobalType.Class:break;case e.GlobalType.Function:break;case e.GlobalType.Value:o.configurable=!0}try{Object.defineProperty(t.container,t.name,o)}catch(r){console.log("2: "+r)}}}})}},t}();e.GlobalScope=t}(TypeMoq||(TypeMoq={}));var TypeMoqStatic;if(function(e){e.Mock=TypeMoq.Mock,e.MockBehavior=TypeMoq.MockBehavior,e.It=TypeMoq.It,e.Times=TypeMoq.Times,e.GlobalMock=TypeMoq.GlobalMock,e.GlobalScope=TypeMoq.GlobalScope,e.MockException=TypeMoq.Error.MockException}(TypeMoqStatic||(TypeMoqStatic={})),typemoq=TypeMoqStatic,"undefined"!=typeof require)var _=require("underscore");"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=typemoq),exports.typemoq=typemoq):this.typemoq=typemoq; |
@@ -30,3 +30,3 @@ declare module TypeMoq { | ||
static ofInstance<U>(instance: U, name?: string, container?: Object, behavior?: MockBehavior): GlobalMock<U>; | ||
static ofType<U>(ctor: Ctor<U>, container?: Object, behavior?: MockBehavior): GlobalMock<U>; | ||
static ofType<U>(ctor: Ctor<U>, name?: string, container?: Object, behavior?: MockBehavior): GlobalMock<U>; | ||
object: T; | ||
@@ -93,8 +93,2 @@ name: string; | ||
/// <reference path="ICallback.d.ts" /> | ||
/// <reference path="IReturns.d.ts" /> | ||
/// <reference path="ISetup.d.ts" /> | ||
/// <reference path="IThrows.d.ts" /> | ||
/// <reference path="IUsing.d.ts" /> | ||
/// <reference path="IVerifies.d.ts" /> | ||
@@ -191,6 +185,2 @@ | ||
/// <reference path="Ctor.d.ts" /> | ||
/// <reference path="Func.d.ts" /> | ||
/// <reference path="PropertyRetriever.d.ts" /> | ||
/// <reference path="Utils.d.ts" /> | ||
@@ -228,4 +218,2 @@ | ||
/// <reference path="Exception.d.ts" /> | ||
/// <reference path="MockException.d.ts" /> | ||
@@ -241,3 +229,2 @@ | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Match { | ||
@@ -265,3 +252,2 @@ class MatchAnyObject<T> implements IMatch { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Match { | ||
@@ -277,8 +263,4 @@ class MatchValue<T> implements IMatch { | ||
/// <reference path="IMatch.d.ts" /> | ||
/// <reference path="MatchAny.d.ts" /> | ||
/// <reference path="MatchValue.d.ts" /> | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Proxy { | ||
@@ -294,3 +276,2 @@ interface ICallContext { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Proxy { | ||
@@ -348,3 +329,2 @@ interface ICallInterceptor { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Proxy { | ||
@@ -366,3 +346,2 @@ interface IProxyCall<T> { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Proxy { | ||
@@ -375,3 +354,2 @@ interface IProxyFactory { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Proxy { | ||
@@ -393,3 +371,2 @@ class Proxy<T> { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq.Proxy { | ||
@@ -402,9 +379,2 @@ class ProxyFactory implements IProxyFactory { | ||
/// <reference path="ICallContext.d.ts" /> | ||
/// <reference path="ICallInterceptor.d.ts" /> | ||
/// <reference path="Invocation.d.ts" /> | ||
/// <reference path="IProxyCall.d.ts" /> | ||
/// <reference path="IProxyFactory.d.ts" /> | ||
/// <reference path="Proxy.d.ts" /> | ||
/// <reference path="ProxyFactory.d.ts" /> | ||
@@ -434,3 +404,2 @@ | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq { | ||
@@ -460,3 +429,2 @@ enum InterceptionAction { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq { | ||
@@ -478,3 +446,2 @@ class InterceptorExecute<T> implements Proxy.ICallInterceptor { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq { | ||
@@ -489,3 +456,2 @@ class InterceptorSetup<T> implements Proxy.ICallInterceptor { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq { | ||
@@ -511,3 +477,2 @@ class AddActualInvocation<T> implements IInterceptStrategy<T> { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq { | ||
@@ -570,3 +535,2 @@ class It { | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq { | ||
@@ -625,23 +589,2 @@ enum MockBehavior { | ||
/// <reference path="../bower_components/DefinitelyTyped/underscore/underscore.d.ts" /> | ||
/// <reference path="Api/_all.d.ts" /> | ||
/// <reference path="Common/_all.d.ts" /> | ||
/// <reference path="Error/_all.d.ts" /> | ||
/// <reference path="Match/_all.d.ts" /> | ||
/// <reference path="Proxy/_all.d.ts" /> | ||
/// <reference path="Constants.d.ts" /> | ||
/// <reference path="CurrentInterceptContext.d.ts" /> | ||
/// <reference path="GlobalMock.d.ts" /> | ||
/// <reference path="GlobalScope.d.ts" /> | ||
/// <reference path="IGlobalMock.d.ts" /> | ||
/// <reference path="IMock.d.ts" /> | ||
/// <reference path="InterceptorContext.d.ts" /> | ||
/// <reference path="InterceptorExecute.d.ts" /> | ||
/// <reference path="InterceptorSetup.d.ts" /> | ||
/// <reference path="InterceptorStrategies.d.ts" /> | ||
/// <reference path="It.d.ts" /> | ||
/// <reference path="MethodCall.d.ts" /> | ||
/// <reference path="MethodCallReturn.d.ts" /> | ||
/// <reference path="Mock.d.ts" /> | ||
/// <reference path="Times.d.ts" /> | ||
import api = TypeMoq.Api; | ||
@@ -653,3 +596,2 @@ import error = TypeMoq.Error; | ||
/// <reference path="_all.d.ts" /> | ||
declare module TypeMoq { | ||
@@ -665,5 +607,25 @@ class GlobalScope implements api.IUsingResult { | ||
/// <reference path="../bower_components/DefinitelyTyped/node/node.d.ts" /> | ||
interface ITypeMoqStatic { | ||
Mock: typeof TypeMoq.Mock; | ||
MockBehavior: typeof TypeMoq.MockBehavior; | ||
It: typeof TypeMoq.It; | ||
Times: typeof TypeMoq.Times; | ||
GlobalMock: typeof TypeMoq.GlobalMock; | ||
GlobalScope: typeof TypeMoq.GlobalScope; | ||
MockException: typeof TypeMoq.Error.MockException; | ||
} | ||
declare module TypeMoqStatic { | ||
export import Mock = TypeMoq.Mock; | ||
export import MockBehavior = TypeMoq.MockBehavior; | ||
export import It = TypeMoq.It; | ||
export import Times = TypeMoq.Times; | ||
export import GlobalMock = TypeMoq.GlobalMock; | ||
export import GlobalScope = TypeMoq.GlobalScope; | ||
export import MockException = TypeMoq.Error.MockException; | ||
} | ||
declare var typemoq: ITypeMoqStatic; | ||
//# sourceMappingURL=output.d.ts.map |
/// <reference path="./typemoq.d.ts" /> | ||
declare module "typemoq" { | ||
export = TypeMoq; | ||
export = typemoq; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2148
421
228739
32