Socket
Socket
Sign inDemoInstall

typemoq

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typemoq - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

v1.4.0 / 2017-03-19
===================
* fix dynamic mock not matching optional params #53
* enable dynamic mock to return 'undefined' for property value #50
v1.3.1 / 2017-03-09

@@ -2,0 +8,0 @@ ===================

2

dist/typemoq-min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],e):e(t.TypeMoq=t.TypeMoq||{},t._)}(this,function(t,e){!function(t){t[t.Loose=0]="Loose",t[t.Strict=1]="Strict"}(t.MockBehavior||(t.MockBehavior={})),function(t){t[t.InAnyOrder=0]="InAnyOrder",t[t.InSequence=1]="InSequence"}(t.ExpectedCallType||(t.ExpectedCallType={}));var n=function(){function t(t,n,r,o){this._condition=t,this.min=n,this.max=r,this._failMessage=e.template(o)}return t.prototype.failMessage=function(t){return this._failMessage({i:t,n:this.min,m:this._lastCallCount})},t.prototype.verify=function(t){return this._lastCallCount=t,this._condition(t)},t.exactly=function(e){return new t(function(t){return t===e},e,e,t.NO_MATCHING_CALLS_EXACTLY_N_TIMES)},t.never=function(){return t.exactly(0)},t.once=function(){return t.exactly(1)},t.atLeastOnce=function(){return new t(function(t){return t>=1},1,255,t.NO_MATCHING_CALLS_AT_LEAST_ONCE)},t.atMostOnce=function(){return new t(function(t){return t>=0&&1>=t},0,1,t.NO_MATCHING_CALLS_AT_MOST_ONCE)},t}();n.NO_MATCHING_CALLS_EXACTLY_N_TIMES="expected invocation of <%= i %> <%= n %> times, invoked <%= m %> times",n.NO_MATCHING_CALLS_AT_LEAST_ONCE="expected invocation of <%= i %> at least once, invoked <%= m %> times",n.NO_MATCHING_CALLS_AT_MOST_ONCE="expected invocation of <%= i %> at most once, invoked <%= m %> times";var r,o=function(){function t(){}return t.getOwnEnumerables=function(t){return this._getPropertyNames(t,!0,!1,this._enumerable)},t.getOwnNonenumerables=function(t){return this._getPropertyNames(t,!0,!1,this._notEnumerable)},t.getOwnEnumerablesAndNonenumerables=function(t){return this._getPropertyNames(t,!0,!1,this._enumerableAndNotEnumerable)},t.getPrototypeEnumerables=function(t){return this._getPropertyNames(t,!1,!0,this._enumerable)},t.getPrototypeNonenumerables=function(t){return this._getPropertyNames(t,!1,!0,this._notEnumerable)},t.getPrototypeEnumerablesAndNonenumerables=function(t){return this._getPropertyNames(t,!1,!0,this._enumerableAndNotEnumerable)},t.getOwnAndPrototypeEnumerables=function(t){return this._getPropertyNames(t,!0,!0,this._enumerable)},t.getOwnAndPrototypeNonenumerables=function(t){return this._getPropertyNames(t,!0,!0,this._notEnumerable)},t.getOwnAndPrototypeEnumerablesAndNonenumerables=function(t){return this._getPropertyNames(t,!0,!0,this._enumerableAndNotEnumerable)},t._enumerable=function(t,e){return t.propertyIsEnumerable(e)},t._notEnumerable=function(t,e){return!t.propertyIsEnumerable(e)},t._enumerableAndNotEnumerable=function(t,e){return!0},t._getPropertyNames=function(t,n,r,o){var i=[];do{if(n)for(var u=Object.getOwnPropertyNames(t),c=function(n){var r=e.find(i,function(t){return t.name===n});if(!r&&o(t,n)){var u=Object.getOwnPropertyDescriptor(t,n);i.push({name:n,desc:u})}},a=0,s=u;a<s.length;a++){var p=s[a];c(p)}if(!r)break;n=!0}while(t=Object.getPrototypeOf(t));return i},t}(),i=function(){function t(){}return t.functionName=function(t){var e;if(t.name)e=t.name;else{var n=t.toString();n=n.substr("function ".length),e=n.substr(0,n.indexOf("("))}return e},t.objectName=function(e){var n=t.functionName(e.constructor);return n},t.argsName=function(t){var n=e.join(t);return n},t.conthunktor=function(t,e){var n=new(t.bind.apply(t,[void 0].concat(e)));return n},t.clone=function(t,e){for(var n=o.getOwnAndPrototypeEnumerablesAndNonenumerables(e),r=0,i=n;r<i.length;r++){var u=i[r];Object.defineProperty(t,u.name,u.desc)}},t}(),u=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),c=function(t){function e(n,r){var o=t.call(this,r)||this;return o.name=n,Object.setPrototypeOf(o,e.prototype),o}return u(e,t),e.prototype.toString=function(){var t=this.message?this.name+" - "+this.message:this.name;return t},e}(Error),a=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t[t.NoSetup="no setup expression found for"]="NoSetup",t[t.MoreThanOneSetup="more than one setup expression found for"]="MoreThanOneSetup",t[t.InvalidSetup="invalid setup expression"]="InvalidSetup",t[t.InvalidMatcher="invalid matching expression"]="InvalidMatcher",t[t.InvalidProxyArg="invalid proxy argument"]="InvalidProxyArg",t[t.UnknownGlobalType="unknown global type"]="UnknownGlobalType",t[t.CallCountVerificationFailed="invocation count verification failed"]="CallCountVerificationFailed",t[t.CallOrderVerificationFailed="invocation order verification failed"]="CallOrderVerificationFailed",t[t.InvalidDynamicProxyRuntime="invalid dynamic proxy runtime"]="InvalidDynamicProxyRuntime"}(r||(r={}));var s=function(t){function e(n,r,o){void 0===o&&(o=void 0);var i=t.call(this,"MockException",o)||this;return i.reason=n,i.ctx=r,i.message=o,Object.setPrototypeOf(i,e.prototype),i}return a(e,t),e.prototype.toString=function(){var t=this.name+" - "+this.reason;return this.message&&(t=t+" ("+this.message+")"),t},e}(c),p=function(){function t(){}return t}();p.IMATCH_ID_VALUE="438A51D3-6864-49D7-A655-CA1153B86965",p.IMATCH_ID_NAME="___id",p.IMATCH_MATCHES_NAME="___matches",p.IPROXY_ID_VALUE="BCDF5CE5-F0DF-40B7-8BA0-69DF395033C8",p.IPROXY_ID_NAME="___id";var f,l=function(){function t(t){this._ctor=t,this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var e=!1;return this._ctor.prototype===t.constructor.prototype&&(e=!0),e},t.prototype.toString=function(){var t="It.isAnyObject("+i.functionName(this._ctor)+")";return t},t}(),h=function(){function t(){this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var e=!0;return e},t.prototype.toString=function(){return"It.isAny()"},t}(),y=function(){function t(){this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var n=!1;return e.isString(t)&&(n=!0),n},t.prototype.toString=function(){return"It.isAnyString()"},t}(),_=function(){function t(){this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var n=!1;return e.isNumber(t)&&(n=!0),n},t.prototype.toString=function(){return"It.isAnyNumber()"},t}(),d=function(){function t(t){this._pred=t,this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var e=!1;return this._pred(t)&&(e=!0),e},t.prototype.toString=function(){var t="It.is("+this._pred+")";return t},t}(),v=function(){function t(t){this._value=t,this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var n=!1;return e.isEqual(this._value,t)&&(n=!0),n},t.prototype.toString=function(){var t="It.isValue("+this._value+")";return t},t}(),b=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),m=function(){function t(){}return t}(),g=function(t){function e(e,n,r){var o=t.call(this)||this;return o._that=e,o._property=n,o._args=r,o}return b(e,t),Object.defineProperty(e.prototype,"args",{get:function(){return this._args||{length:0,callee:null}},set:function(t){this._args=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){var t={};this._that?i.clone(t,this._that):t=this._property.obj,this.returnValue=this._property.toFunc.apply(t,this._args)},e.prototype.toString=function(){var t=this.property+"("+i.argsName(this.args)+")";return t},e}(m),C=function(t){function e(e,n){var r=t.call(this)||this;return r._property=e,r.value=n,r.returnValue=n,r}return b(e,t),Object.defineProperty(e.prototype,"args",{get:function(){var t=[];return Object.defineProperty(t,"callee",{configurable:!0,enumerable:!0,writable:!1,value:null}),t},set:function(t){},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]},e.prototype.toString=function(){var t=""+this.property;return t},e}(m),w=function(t){function e(e,n){var r=t.call(this)||this;return r._property=e,r._args=n,r}return b(e,t),Object.defineProperty(e.prototype,"args",{get:function(){return this._args},set:function(t){this._args=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this._property.obj[this._property.name]=this._args[0],this.returnValue=this._property.obj[this._property.name]},e.prototype.toString=function(){var t=this.property+" = "+i.argsName(this.args[0]);return t},e}(m),O=function(t){function e(e,n){var r=t.call(this)||this;return r._property=e,r._getter=n,r}return b(e,t),Object.defineProperty(e.prototype,"args",{get:function(){var t=[];return Object.defineProperty(t,"callee",{configurable:!0,enumerable:!0,writable:!1,value:null}),t},set:function(t){},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]},e.prototype.toString=function(){var t=""+this.property;return t},e}(m),P=function(t){function e(e,n,r){var o=t.call(this)||this;return o._property=e,o._setter=n,o._args=r,o}return b(e,t),Object.defineProperty(e.prototype,"args",{get:function(){return this._args},set:function(t){this._args=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this._property.obj[this._property.name]=this._args[0],this.returnValue=this._property.obj[this._property.name]},e.prototype.toString=function(){var t=this.property+"("+i.argsName(this.args[0])+")";return t},e}(m),I=function(){function t(t,e,n){this.obj=t,this.name=e,this.desc=n}return Object.defineProperty(t.prototype,"toFunc",{get:function(){var t;return t=e.isFunction(this.obj)?this.obj:this.obj[this.name]},enumerable:!0,configurable:!0}),t.prototype.toString=function(){var t=i.objectName(this.obj),e=t+"."+this.name;return e},t}(),x=function(){function t(t,e,n){this.obj=t,this.name=e,this.desc=n}return t.prototype.toString=function(){var t=i.objectName(this.obj),e=t+"."+this.name;return e},t}(),A=function(){function t(t,n){var r=this;this.___id=p.IPROXY_ID_VALUE,this.check(n);var i=this,u=o.getOwnAndPrototypeEnumerablesAndNonenumerables(n);e.each(u,function(o){if(e.isFunction(o.desc.value)){var u={configurable:o.desc.configurable,enumerable:o.desc.enumerable,writable:o.desc.writable};r.defineMethodProxy(i,t,n,o.name,u)}else{var u={configurable:o.desc.configurable,enumerable:o.desc.enumerable};void 0!==o.desc.value?r.defineValuePropertyProxy(i,t,n,o.name,o.desc.value,u):r.defineGetSetPropertyProxy(i,t,n,o.name,o.desc.get,o.desc.set,u)}})}return t.of=function(n,r){t.check(n);var o;if(e.isFunction(n)){var u=i.functionName(n);o=t.methodProxyValue(void 0,r,n,u,null)}else o=new t(r,n);return o},t.isProxy=function(t){return e.isNil(t)||e.isUndefined(t[p.IPROXY_ID_NAME])||t[p.IPROXY_ID_NAME]!==p.IPROXY_ID_VALUE?!1:!0},t.check=function(n){t.checkNotNullOrUndefined(n);var o=!1;if((e.isFunction(n)||e.isObject(n)&&!t.isPrimitiveObject(n))&&(o=!0),!o)throw new s(r.InvalidProxyArg,n,"'"+n+"'; argument should be a function or a non primitive object")},t.prototype.check=function(n){t.checkNotNullOrUndefined(n);var o=!1;if(e.isFunction(n)||!e.isObject(n)||t.isPrimitiveObject(n)||(o=!0),!o)throw new s(r.InvalidProxyArg,n,"'"+n+"'; argument should be a non primitive object")},t.checkNotNullOrUndefined=function(t){if(e.isNil(t))throw new s(r.InvalidProxyArg,t,"'"+t+"'; argument is required")},t.isPrimitiveObject=function(t){var n=!1;return(e.isFunction(t)||e.isArray(t)||e.isDate(t)||e.isNull(t))&&(n=!0),n},t.prototype.defineMethodProxy=function(e,n,r,o,i){void 0===i&&(i={configurable:!0,enumerable:!0,writable:!1}),i.value=t.methodProxyValue(e,n,r,o,i),this.defineProperty(e,o,i)},t.methodProxyValue=function(t,e,n,r,o){function i(){var i=new I(n,r,o),u=new g(t,i,arguments);return e.intercept(u),u.returnValue}return i},t.prototype.defineValuePropertyProxy=function(t,e,n,r,o,i){function u(){var t=new x(n,r),i=new C(t,o);return e.intercept(i),i.returnValue}function c(t){var o=new x(n,r),i=new w(o,arguments);e.intercept(i)}void 0===i&&(i={configurable:!0,enumerable:!0}),i.get=u,i.set=c,this.defineProperty(t,r,i)},t.prototype.defineGetSetPropertyProxy=function(t,e,n,r,o,i,u){function c(){var t=new x(n,r),i=new O(t,o);return e.intercept(i),i.returnValue}function a(t){var o=new x(n,r),u=new P(o,i,arguments);e.intercept(u)}void 0===u&&(u={configurable:!0,enumerable:!0}),u.get=c,u.set=a,this.defineProperty(t,r,u)},t.prototype.defineProperty=function(t,e,n){try{Object.defineProperty(t,e,n)}catch(r){console.log(r.message)}},t}(),j=function(){function t(t){this.___id=p.IPROXY_ID_VALUE;var e=new Proxy(function(){},t);return e}return t.of=function(e){t.check();var n=new t(e);return n},t.check=function(){if("undefined"==typeof Proxy)throw new s(r.InvalidDynamicProxyRuntime,null,"ES6 Proxy object not detected; the dynamic mocking feature requires ES6 Proxy object support")},t}(),E=function(){function t(t){this._interceptor=t}return t.prototype.apply=function(t,e,n){var r=i.functionName(t),o=new I(t,r),u=new g(t,o,n);return this._interceptor.intercept(u),u.returnValue},t.prototype.get=function(t,n,r){var o=this,i=t[n],u=new x(t,n,{value:!0}),c=new C(u,i);return this._interceptor.intercept(c),!e.isFunction(i)&&!e.isUndefined(c.returnValue)&&c.property.desc&&c.property.desc.value?c.returnValue:function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];o._interceptor.removeInvocation(c);var i=new I(t,n),u=new g(t,i,e);return o._interceptor.intercept(u),u.returnValue}},t.prototype.set=function(t,e,n,r){var o=new x(t,e),i=new w(o,[n]);return this._interceptor.intercept(i),Reflect.set(t,e,n,r)},t.prototype.defineProperty=function(t,e,n){return n.configurable=!0,Reflect.defineProperty(t,e,n)},t}(),k=function(){function t(){}return t.createProxy=function(t,e){var n=A.of(e,t);return n},t.createProxyES6=function(t){var e=new E(t),n=j.of(e);return n},t}(),N=function(){function n(e,n,r){void 0===r&&(r=t.MockBehavior.Loose),this.targetInstance=e,this.canOverrideTarget=n,this.behavior=r,this._id=this.generateId(),this._name=this.getNameOf(this.targetInstance)}return 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,"callBase",{get:function(){return this._callBase},set:function(t){this._callBase=t},enumerable:!0,configurable:!0}),n.prototype.generateId=function(){return"Mock<"+e.uniqueId()+">"},n.prototype.getNameOf=function(t){var n;if(e.isFunction(t))n=i.functionName(t);else if(e.isObject(t)){var r=t.constructor;n=i.functionName(r)}return n&&(n=n.trim()),n},n.prototype.verifyAll=function(){try{this._interceptor.verify()}catch(t){throw t}},n.prototype.reset=function(){this._interceptor.reset()},n}();!function(t){t[t.Continue=0]="Continue",t[t.Stop=1]="Stop"}(f||(f={}));var M,S=function(){function t(t){this.mock=t,this._actualInvocations=[],this._expectedCalls=[]}return Object.defineProperty(t.prototype,"behavior",{get:function(){return this.mock.behavior},enumerable:!0,configurable:!0}),t.prototype.addInvocation=function(t){this._actualInvocations.push(t)},t.prototype.removeInvocation=function(t){e.remove(this._actualInvocations,function(e){return e===t})},t.prototype.actualInvocations=function(){return this._actualInvocations},t.prototype.clearInvocations=function(){this._actualInvocations.splice(0,this._actualInvocations.length)},t.prototype.addExpectedCall=function(t){this._expectedCalls.push(t)},t.prototype.removeExpectedCall=function(t){e.filter(this._expectedCalls,function(e){return e.id!==t.id})},t.prototype.expectedCalls=function(){return this._expectedCalls},t.prototype.clearExpectedCalls=function(){this._expectedCalls.splice(0,this._expectedCalls.length)},t.prototype.reset=function(){this.clearInvocations(),this.clearExpectedCalls()},t}(),T=function(){function t(){}return t}(),V=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){return e.addInvocation(t),f.Continue},t}(),L=function(){function n(){}return n.prototype.handleIntercept=function(n,o,i){var u=o.expectedCalls().slice(),c=function(t){return t.matches(n)},a=e.filter(u,function(t){return c(t)});if(a.length>1&&(c=function(t){return!t.isInvoked&&t.matches(n)}),i.call=e.find(u,function(t){return c(t)}),null!=i.call)i.call.evaluatedSuccessfully();else if(o.behavior==t.MockBehavior.Strict)throw new s(r.NoSetup,n,"'"+n+"'");return f.Continue},n}(),D=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){this._ctx=e;var r=n.call;return null!=r?(r.execute(t),f.Stop):f.Continue},t}(),B=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){return e.mock.callBase?(t.invokeBase(),f.Stop):f.Continue},t}(),F=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){return f.Continue},t}(),U=function(){function t(t){this._interceptorContext=new S(t)}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 T;e.some(this.interceptionStrategies(),function(e){return f.Stop===e.handleIntercept(t,n.interceptorContext,r)?!0:void 0})},t.prototype.removeInvocation=function(t){this._interceptorContext.removeInvocation(t)},t.prototype.addExpectedCall=function(t){this._interceptorContext.addExpectedCall(t)},t.prototype.verify=function(){for(var t=this._interceptorContext.expectedCalls(),n=e.filter(t,function(t){return t.isVerifiable}),r=0,o=n;r<o.length;r++){var i=o[r];this.verifyCallCount(i,i.expectedCallCount)}var u=e.filter(t,function(t){return t.isInSequence});this.verifyCallsOrder(u)},t.prototype.verifyCallCount=function(t,n){var r=this._interceptorContext.actualInvocations(),o=e.filter(r,function(e){return t.matches(e)}).length;n.verify(o)||this.throwVerifyCallCountException(t.setupCall,n)},t.prototype.throwVerifyCallCountException=function(t,e){var n=new s(r.CallCountVerificationFailed,t,e.failMessage(t));throw n},t.prototype.verifyCallsOrder=function(t){var e=this._interceptorContext.actualInvocations();this.checkCallOrderExpectations(t,e)},t.prototype.checkCallOrderExpectations=function(t,n){var r=function(r){for(var o=e.sum(r),i=0,u=0;u<r.length;u++)for(var c=t[u],a=r[u],s=1;a>=s;s++){var p=n[i++];if(!c.matches(p))return!1}return i===o},o=!1,i=function(e,n){if(!o)if(n===t.length)o=r(e);else for(var u=t[n].expectedCallCount.min;u<=t[n].expectedCallCount.max;u++)e[n]=u,i(e,n+1)};i([],0),o||this.throwVerifyCallOrderException()},t.prototype.throwVerifyCallOrderException=function(){var t=new s(r.CallOrderVerificationFailed,null);throw t},t.prototype.reset=function(){this._interceptorContext.reset()},t.prototype.interceptionStrategies=function(){var t=[new V,new L,new D,new B,new F];return t},t}(),H=function(){function t(){}return Object.defineProperty(t.prototype,"interceptedCall",{get:function(){return this._interceptedCall},enumerable:!0,configurable:!0}),t.prototype.intercept=function(t){if(this._interceptedCall)throw new s(r.MoreThanOneSetup,t,"'"+t+"'; setup should contain only one expression");this._interceptedCall=t},t.prototype.removeInvocation=function(t){this._interceptedCall&&this._interceptedCall===t&&(this._interceptedCall=void 0)},t}(),G=function(){function o(t,e,n,o){if(this.mock=t,this._setupExpression=e,this._callCount=0,this._id=this.generateId(),e(o),!n.interceptedCall)throw new s(r.InvalidSetup,this._setupExpression,"'"+this._setupExpression+"'");var i=n.interceptedCall,u=this.transformToMatchers(i.args);Object.defineProperty(u,"callee",{configurable:!0,enumerable:!0,writable:!1,value:i.args.callee}),i.args=u,this._setupCall=i}return o.ofStaticMock=function(t,e){var n=new H,r=k.createProxy(n,t.targetInstance),i=new o(t,e,n,r);return i},o.ofDynamicMock=function(t,e){var n=new H,r=k.createProxyES6(n),i=new o(t,e,n,r);return i},o.prototype.generateId=function(){return"MethodCall<"+e.uniqueId()+">"},o.prototype.transformToMatchers=function(t){var n=[];return e.each(t,function(t){if(e.isObject(t))if(e.isUndefined(t[p.IMATCH_MATCHES_NAME])||e.isUndefined(t[p.IMATCH_ID_NAME])||t[p.IMATCH_ID_NAME]!==p.IMATCH_ID_VALUE){var r=new d(function(e){return e===t});n.push(r)}else n.push(t);else{var r=new v(t);n.push(r)}}),n},Object.defineProperty(o.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"setupExpression",{get:function(){return this._setupExpression},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"setupCall",{get:function(){return this._setupCall},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isVerifiable",{get:function(){return this._isVerifiable},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isInSequence",{get:function(){return this._expectedCallType===t.ExpectedCallType.InSequence},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"expectedCallCount",{get:function(){return this._expectedCallCount},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isInvoked",{get:function(){return this._isInvoked},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"callCount",{get:function(){return this._callCount},enumerable:!0,configurable:!0}),o.prototype.evaluatedSuccessfully=function(){this._evaluatedSuccessfully=!0},o.prototype.matches=function(t){var n=!1;return this._setupCall.property&&t&&t.property&&this._setupCall.property.name===t.property.name&&this._setupCall.args.length===t.args.length&&(n=!0,e.each(this.setupCall.args,function(e,r){var o=e,i=t.args[r];n&&!o.___matches(i)&&(n=!1)})),n},o.prototype.execute=function(t){if(this._isInvoked=!0,null!=this._setupCallback&&this._setupCallback.apply(this,t.args),null!=this._thrownException)throw this._thrownException;this._callCount++},o.prototype.verifiable=function(e,r){void 0===e&&(e=n.atLeastOnce()),void 0===r&&(r=t.ExpectedCallType.InAnyOrder),this._isVerifiable=!0,this._expectedCallCount=e,this._expectedCallType=r},o}(),R=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),q=function(t){function e(e,n,r,o){var i=t.call(this,e,n,r,o)||this;return i._overrideTarget=e.canOverrideTarget,i}return R(e,t),e.ofStaticMock=function(t,n){var r=new H,o=k.createProxy(r,t.targetInstance),i=new e(t,n,r,o);return i},e.ofDynamicMock=function(t,n){var r=new H,o=k.createProxyES6(r),i=new e(t,n,r,o);return i},e.prototype.execute=function(e){t.prototype.execute.call(this,e),this._callBase?e.invokeBase():this.hasReturnValue&&(e.returnValue=this._returnValueFunc.apply(this,e.args),e.property.desc={value:this.setupCall.property.desc&&this.setupCall.property.desc.value})},e.prototype.callback=function(t){return this._setupCallback=t,this},e.prototype["throws"]=function(t){return this._thrownException=t,this},e.prototype.returns=function(t){if(this._returnValueFunc=t,this.hasReturnValue=!0,this._overrideTarget){var e=this.mock.targetInstance,n=this.setupCall.property.name,r=this.setupCall.property.desc;r&&(r.configurable=!0,r.enumerable=!0,r.value=this._returnValueFunc,Object.defineProperty(e,n,r))}return this},e.prototype.callBase=function(){return this._callBase=!0,this},e}(G),X=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Y=function(t){function n(e,n,r){var o=t.call(this,e,n,r)||this;return o._interceptor=new U(o),o._proxy=k.createProxy(o._interceptor,e),o}return X(n,t),n.ofInstance=function(t,e){t=n.cloneDeep(t);var r=new n(t,!0,e);return r},n.ofGlobalInstance=function(t,e){var r=new n(t,!1,e);return r},n.ofType=function(t,e,r){var o=i.conthunktor(t,r),u=new n(o,!0,e);return u},n.cloneDeep=function(t){var n=t;if(!e.isFunction(t)){var r=function(t){return A.isProxy(t)?t:void 0};n=e.cloneDeepWith(t,r)}return n},n.prototype.setup=function(t){var e=q.ofStaticMock(this,t);return this._interceptor.addExpectedCall(e),e},n.prototype.verify=function(t,e){var n=G.ofStaticMock(this,t);this._interceptor.addExpectedCall(n);try{this._interceptor.verifyCallCount(n,e)}catch(r){throw r}},n}(N),W=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),z=function(t){function e(e,n,r){var o=t.call(this,{},n,r)||this;return e&&(o._name=e),o._interceptor=new U(o),o._proxy=k.createProxyES6(o._interceptor),o}return W(e,t),e.ofType=function(t,n){var r=new e(t,!0,n);return r},e.prototype.setup=function(t){var e=q.ofDynamicMock(this,t);return this._interceptor.addExpectedCall(e),e},e.prototype.verify=function(t,e){var n=G.ofDynamicMock(this,t);this._interceptor.addExpectedCall(n);try{this._interceptor.verifyCallCount(n,e)}catch(r){throw r}},e}(N),J=function(){function e(){}return e.ofInstance=function(e,n){void 0===n&&(n=t.MockBehavior.Loose);var r=Y.ofInstance(e,n);return r},e.ofType=function(n,r){void 0===r&&(r=t.MockBehavior.Loose);for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];var u;return u=n?e.ofType2(n,o,r):z.ofType(void 0,r)},e.ofType2=function(e,n,r){void 0===r&&(r=t.MockBehavior.Loose);var o=Y.ofType(e,r,n);return o},e}(),K=function(){function t(){}return t.isValue=function(t){var e=new v(t);return e},t.isAnyObject=function(t){var e=new l(t);return e},t.isAny=function(){var t=new h;return t},t.isAnyString=function(){var t=new y;return t},t.isAnyNumber=function(){var t=new _;return t},t.is=function(t){var e=new d(t);return e},t}();!function(t){t[t.Class=0]="Class",t[t.Function=1]="Function",t[t.Value=2]="Value"}(M||(M={}));var Q=function(){function t(t,e,n,r){this.mock=t,this._name=e,this._type=n,this.container=r,this._name||(this._name=t.name)}return 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(t){this.mock.callBase=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),t.prototype.setup=function(t){return this.mock.setup(t)},t.prototype.verify=function(t,e){this.mock.verify(t,e)},t.prototype.verifyAll=function(){this.mock.verifyAll()},t.prototype.reset=function(){this.mock.reset()},t}(),Z=function(){function n(){}return n.ofInstance=function(n,r,o,i){void 0===o&&(o=window),void 0===i&&(i=t.MockBehavior.Loose);var u=Y.ofGlobalInstance(n,i),c=e.isFunction(n)?M.Function:M.Value;return new Q(u,r,c,o)},n.ofType=function(e,n,r){void 0===n&&(n=window),void 0===r&&(r=t.MockBehavior.Loose);var o=new e,i=Y.ofInstance(o,r);return new Q(i,void 0,M.Class,n)},n.ofType2=function(e,n,r){void 0===n&&(n=window),void 0===r&&(r=t.MockBehavior.Loose);var o=z.ofType(e,r);return new Q(o,void 0,M.Class,n)},n}(),$=function(){function t(t){this._args=t}return t.prototype["with"]=function(t){var n={};try{e.each(this._args,function(t){var i=o.getOwnAndPrototypeEnumerablesAndNonenumerables(t.container),u=e.find(i,function(e){return e.name===t.name});if(u){n[t.name]=u.desc;var c={};switch(t.type){case M.Class:c.value=function(){return t.mock.object};break;case M.Function:c.value=t.mock.object;break;case M.Value:c.get=function(){return t.mock.object};break;default:throw new s(r.UnknownGlobalType,t,"unknown global type: "+t.type)}try{Object.defineProperty(t.container,t.name,c)}catch(a){console.log("1: "+a)}}}),t.apply(this,this._args)}catch(i){console.log("2: "+i)}finally{e.each(this._args,function(t){var e=n[t.name];if(e){switch(t.type){case M.Class:break;case M.Function:break;case M.Value:e.configurable=!0}try{Object.defineProperty(t.container,t.name,e)}catch(r){console.log("3: "+r)}}})}},t}(),tt=function(){function t(){}return t.using=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new $(t);return n},t}();t.Mock=J,t.It=K,t.Times=n,t.GlobalMock=Z,t.GlobalScope=tt,t.MockException=s,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],e):e(t.TypeMoq=t.TypeMoq||{},t._)}(this,function(t,e){!function(t){t[t.Loose=0]="Loose",t[t.Strict=1]="Strict"}(t.MockBehavior||(t.MockBehavior={})),function(t){t[t.InAnyOrder=0]="InAnyOrder",t[t.InSequence=1]="InSequence"}(t.ExpectedCallType||(t.ExpectedCallType={}));var n=function(){function t(t,n,r,o){this._condition=t,this.min=n,this.max=r,this._failMessage=e.template(o)}return t.prototype.failMessage=function(t){return this._failMessage({i:t,n:this.min,m:this._lastCallCount})},t.prototype.verify=function(t){return this._lastCallCount=t,this._condition(t)},t.exactly=function(e){return new t(function(t){return t===e},e,e,t.NO_MATCHING_CALLS_EXACTLY_N_TIMES)},t.never=function(){return t.exactly(0)},t.once=function(){return t.exactly(1)},t.atLeastOnce=function(){return new t(function(t){return t>=1},1,255,t.NO_MATCHING_CALLS_AT_LEAST_ONCE)},t.atMostOnce=function(){return new t(function(t){return t>=0&&1>=t},0,1,t.NO_MATCHING_CALLS_AT_MOST_ONCE)},t}();n.NO_MATCHING_CALLS_EXACTLY_N_TIMES="expected invocation of <%= i %> <%= n %> times, invoked <%= m %> times",n.NO_MATCHING_CALLS_AT_LEAST_ONCE="expected invocation of <%= i %> at least once, invoked <%= m %> times",n.NO_MATCHING_CALLS_AT_MOST_ONCE="expected invocation of <%= i %> at most once, invoked <%= m %> times";var r,o=function(){function t(){}return t.getOwnEnumerables=function(t){return this._getPropertyNames(t,!0,!1,this._enumerable)},t.getOwnNonenumerables=function(t){return this._getPropertyNames(t,!0,!1,this._notEnumerable)},t.getOwnEnumerablesAndNonenumerables=function(t){return this._getPropertyNames(t,!0,!1,this._enumerableAndNotEnumerable)},t.getPrototypeEnumerables=function(t){return this._getPropertyNames(t,!1,!0,this._enumerable)},t.getPrototypeNonenumerables=function(t){return this._getPropertyNames(t,!1,!0,this._notEnumerable)},t.getPrototypeEnumerablesAndNonenumerables=function(t){return this._getPropertyNames(t,!1,!0,this._enumerableAndNotEnumerable)},t.getOwnAndPrototypeEnumerables=function(t){return this._getPropertyNames(t,!0,!0,this._enumerable)},t.getOwnAndPrototypeNonenumerables=function(t){return this._getPropertyNames(t,!0,!0,this._notEnumerable)},t.getOwnAndPrototypeEnumerablesAndNonenumerables=function(t){return this._getPropertyNames(t,!0,!0,this._enumerableAndNotEnumerable)},t._enumerable=function(t,e){return t.propertyIsEnumerable(e)},t._notEnumerable=function(t,e){return!t.propertyIsEnumerable(e)},t._enumerableAndNotEnumerable=function(t,e){return!0},t._getPropertyNames=function(t,n,r,o){var i=[];do{if(n)for(var u=Object.getOwnPropertyNames(t),c=function(n){var r=e.find(i,function(t){return t.name===n});if(!r&&o(t,n)){var u=Object.getOwnPropertyDescriptor(t,n);i.push({name:n,desc:u})}},a=0,s=u;a<s.length;a++){var p=s[a];c(p)}if(!r)break;n=!0}while(t=Object.getPrototypeOf(t));return i},t}(),i=function(){function t(){}return t.functionName=function(t){var e;if(t.name)e=t.name;else{var n=t.toString();n=n.substr("function ".length),e=n.substr(0,n.indexOf("("))}return e},t.objectName=function(e){var n=t.functionName(e.constructor);return n},t.argsName=function(t){var n=e.join(t);return n},t.conthunktor=function(t,e){var n=new(t.bind.apply(t,[void 0].concat(e)));return n},t.clone=function(t,e){for(var n=o.getOwnAndPrototypeEnumerablesAndNonenumerables(e),r=0,i=n;r<i.length;r++){var u=i[r];Object.defineProperty(t,u.name,u.desc)}},t}(),u=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),c=function(t){function e(n,r){var o=t.call(this,r)||this;return o.name=n,Object.setPrototypeOf(o,e.prototype),o}return u(e,t),e.prototype.toString=function(){var t=this.message?this.name+" - "+this.message:this.name;return t},e}(Error),a=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t[t.NoSetup="no setup expression found for"]="NoSetup",t[t.MoreThanOneSetup="more than one setup expression found for"]="MoreThanOneSetup",t[t.InvalidSetup="invalid setup expression"]="InvalidSetup",t[t.InvalidMatcher="invalid matching expression"]="InvalidMatcher",t[t.InvalidProxyArg="invalid proxy argument"]="InvalidProxyArg",t[t.UnknownGlobalType="unknown global type"]="UnknownGlobalType",t[t.CallCountVerificationFailed="invocation count verification failed"]="CallCountVerificationFailed",t[t.CallOrderVerificationFailed="invocation order verification failed"]="CallOrderVerificationFailed",t[t.InvalidDynamicProxyRuntime="invalid dynamic proxy runtime"]="InvalidDynamicProxyRuntime"}(r||(r={}));var s=function(t){function e(n,r,o){void 0===o&&(o=void 0);var i=t.call(this,"MockException",o)||this;return i.reason=n,i.ctx=r,i.message=o,Object.setPrototypeOf(i,e.prototype),i}return a(e,t),e.prototype.toString=function(){var t=this.name+" - "+this.reason;return this.message&&(t=t+" ("+this.message+")"),t},e}(c),p=function(){function t(){}return t}();p.IMATCH_ID_VALUE="438A51D3-6864-49D7-A655-CA1153B86965",p.IMATCH_ID_NAME="___id",p.IMATCH_MATCHES_NAME="___matches",p.IPROXY_ID_VALUE="BCDF5CE5-F0DF-40B7-8BA0-69DF395033C8",p.IPROXY_ID_NAME="___id";var l,f=function(){function t(t){this._ctor=t,this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var e=!1;return t&&t.constructor.prototype==this._ctor.prototype&&(e=!0),e},t.prototype.toString=function(){var t="It.isAnyObject("+i.functionName(this._ctor)+")";return t},t}(),h=function(){function t(){this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var e=!0;return e},t.prototype.toString=function(){return"It.isAny()"},t}(),y=function(){function t(){this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var n=!1;return e.isString(t)&&(n=!0),n},t.prototype.toString=function(){return"It.isAnyString()"},t}(),_=function(){function t(){this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var n=!1;return e.isNumber(t)&&(n=!0),n},t.prototype.toString=function(){return"It.isAnyNumber()"},t}(),d=function(){function t(t){this._pred=t,this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var e=!1;return t&&this._pred(t)&&(e=!0),e},t.prototype.toString=function(){var t="It.is("+this._pred+")";return t},t}(),v=function(){function t(t){this._value=t,this.___id=p.IMATCH_ID_VALUE}return t.prototype.___matches=function(t){var n=!1;return e.isEqual(this._value,t)&&(n=!0),n},t.prototype.toString=function(){var t="It.isValue("+this._value+")";return t},t}();!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.PROPERTY=1]="PROPERTY",t[t.FUNCTION=2]="FUNCTION"}(l||(l={}));var b;!function(t){t[t.STATIC=0]="STATIC",t[t.DYNAMIC=1]="DYNAMIC"}(b||(b={}));var m,g=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t[t.NONE=0]="NONE",t[t.SETUP=1]="SETUP",t[t.EXECUTE=2]="EXECUTE"}(m||(m={}));var C,O=function(){function t(t,e){this.proxyType=t,this.callType=e,this.invocationType=m.NONE}return t}(),I=function(t){function e(e,n,r,o,i){void 0===o&&(o=b.STATIC),void 0===i&&(i=l.FUNCTION);var u=t.call(this,o,i)||this;return u._that=e,u._property=n,u._args=r,u}return g(e,t),Object.defineProperty(e.prototype,"args",{get:function(){return this._args||{length:0,callee:null}},set:function(t){this._args=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){var t={};this._that?i.clone(t,this._that):t=this._property.obj,this.returnValue=this._property.toFunc.apply(t,this._args)},e.prototype.toString=function(){var t=this.property+"("+i.argsName(this.args)+")";return t},e}(O),P=function(t){function e(e,n,r,o){void 0===r&&(r=b.STATIC),void 0===o&&(o=l.PROPERTY);var i=t.call(this,r,o)||this;return i._property=e,i.value=n,i.returnValue=n,i}return g(e,t),Object.defineProperty(e.prototype,"args",{get:function(){var t=[];return Object.defineProperty(t,"callee",{configurable:!0,enumerable:!0,writable:!1,value:null}),t},set:function(t){},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]},e.prototype.toString=function(){var t=""+this.property;return t},e}(O),w=function(t){function e(e,n){var r=t.call(this,e,n,b.DYNAMIC,l.UNKNOWN)||this;return r.returnValue=n,r}return g(e,t),e}(P),N=function(t){function e(e,n,r,o){void 0===r&&(r=b.STATIC),void 0===o&&(o=l.PROPERTY);var i=t.call(this,r,o)||this;return i._property=e,i._args=n,i}return g(e,t),Object.defineProperty(e.prototype,"args",{get:function(){return this._args},set:function(t){this._args=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this._property.obj[this._property.name]=this._args[0],this.returnValue=this._property.obj[this._property.name]},e.prototype.toString=function(){var t=this.property+" = "+i.argsName(this.args[0]);return t},e}(O),x=function(t){function e(e,n,r,o){void 0===r&&(r=b.STATIC),void 0===o&&(o=l.FUNCTION);var i=t.call(this,r,o)||this;return i._property=e,i._getter=n,i}return g(e,t),Object.defineProperty(e.prototype,"args",{get:function(){var t=[];return Object.defineProperty(t,"callee",{configurable:!0,enumerable:!0,writable:!1,value:null}),t},set:function(t){},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]},e.prototype.toString=function(){var t=""+this.property;return t},e}(O),A=function(t){function e(e,n,r,o,i){void 0===o&&(o=b.STATIC),void 0===i&&(i=l.FUNCTION);var u=t.call(this,o,i)||this;return u._property=e,u._setter=n,u._args=r,u}return g(e,t),Object.defineProperty(e.prototype,"args",{get:function(){return this._args},set:function(t){this._args=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"property",{get:function(){return this._property},enumerable:!0,configurable:!0}),e.prototype.invokeBase=function(){this._property.obj[this._property.name]=this._args[0],this.returnValue=this._property.obj[this._property.name]},e.prototype.toString=function(){var t=this.property+"("+i.argsName(this.args[0])+")";return t},e}(O),E=function(){function t(t,e,n){this.obj=t,this.name=e,this.desc=n}return Object.defineProperty(t.prototype,"toFunc",{get:function(){var t;return t=e.isFunction(this.obj)?this.obj:this.obj[this.name]},enumerable:!0,configurable:!0}),t.prototype.toString=function(){var t=i.objectName(this.obj),e=t+"."+this.name;return e},t}(),T=function(){function t(t,e,n){this.obj=t,this.name=e,this.desc=n}return t.prototype.toString=function(){var t=i.objectName(this.obj),e=t+"."+this.name;return e},t}(),j=function(){function t(t,n){var r=this;this.___id=p.IPROXY_ID_VALUE,this.check(n);var i=this,u=o.getOwnAndPrototypeEnumerablesAndNonenumerables(n);e.each(u,function(o){if(e.isFunction(o.desc.value)){var u={configurable:o.desc.configurable,enumerable:o.desc.enumerable,writable:o.desc.writable};r.defineMethodProxy(i,t,n,o.name,u)}else{var u={configurable:o.desc.configurable,enumerable:o.desc.enumerable};void 0!==o.desc.value?r.defineValuePropertyProxy(i,t,n,o.name,o.desc.value,u):r.defineGetSetPropertyProxy(i,t,n,o.name,o.desc.get,o.desc.set,u)}})}return t.of=function(n,r){t.check(n);var o;if(e.isFunction(n)){var u=i.functionName(n);o=t.methodProxyValue(void 0,r,n,u,null)}else o=new t(r,n);return o},t.isProxy=function(t){return e.isNil(t)||e.isUndefined(t[p.IPROXY_ID_NAME])||t[p.IPROXY_ID_NAME]!==p.IPROXY_ID_VALUE?!1:!0},t.check=function(n){t.checkNotNullOrUndefined(n);var o=!1;if((e.isFunction(n)||e.isObject(n)&&!t.isPrimitiveObject(n))&&(o=!0),!o)throw new s(r.InvalidProxyArg,n,"'"+n+"'; argument should be a function or a non primitive object")},t.prototype.check=function(n){t.checkNotNullOrUndefined(n);var o=!1;if(e.isFunction(n)||!e.isObject(n)||t.isPrimitiveObject(n)||(o=!0),!o)throw new s(r.InvalidProxyArg,n,"'"+n+"'; argument should be a non primitive object")},t.checkNotNullOrUndefined=function(t){if(e.isNil(t))throw new s(r.InvalidProxyArg,t,"'"+t+"'; argument is required")},t.isPrimitiveObject=function(t){var n=!1;return(e.isFunction(t)||e.isArray(t)||e.isDate(t)||e.isNull(t))&&(n=!0),n},t.prototype.defineMethodProxy=function(e,n,r,o,i){void 0===i&&(i={configurable:!0,enumerable:!0,writable:!1}),i.value=t.methodProxyValue(e,n,r,o,i),this.defineProperty(e,o,i)},t.methodProxyValue=function(t,e,n,r,o){function i(){var i=new E(n,r,o),u=new I(t,i,arguments);return e.intercept(u),u.returnValue}return i},t.prototype.defineValuePropertyProxy=function(t,e,n,r,o,i){function u(){var t=new T(n,r),i=new P(t,o);return e.intercept(i),i.returnValue}function c(t){var o=new T(n,r),i=new N(o,arguments);e.intercept(i)}void 0===i&&(i={configurable:!0,enumerable:!0}),i.get=u,i.set=c,this.defineProperty(t,r,i)},t.prototype.defineGetSetPropertyProxy=function(t,e,n,r,o,i,u){function c(){var t=new T(n,r),i=new x(t,o);return e.intercept(i),i.returnValue}function a(t){var o=new T(n,r),u=new A(o,i,arguments);e.intercept(u)}void 0===u&&(u={configurable:!0,enumerable:!0}),u.get=c,u.set=a,this.defineProperty(t,r,u)},t.prototype.defineProperty=function(t,e,n){try{Object.defineProperty(t,e,n)}catch(r){console.log(r.message)}},t}(),k=function(){function t(t){this.___id=p.IPROXY_ID_VALUE;var e=new Proxy(function(){},t);return e}return t.of=function(e){t.check();var n=new t(e);return n},t.check=function(){if("undefined"==typeof Proxy)throw new s(r.InvalidDynamicProxyRuntime,null,"ES6 Proxy object not detected; the dynamic mocking feature requires ES6 Proxy object support")},t}(),S=function(){function t(t){this._interceptor=t}return t.prototype.apply=function(t,e,n){var r=i.functionName(t),o=new E(t,r),u=new I(t,o,n,b.DYNAMIC);return this._interceptor.intercept(u),u.returnValue},t.prototype.get=function(t,n,r){var o=this,i=t[n],u=new T(t,n),c=new w(u,i);return this._interceptor.intercept(c),!e.isFunction(i)&&c.callType==l.PROPERTY&&c.property.desc?c.returnValue:function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];o._interceptor.removeInvocation(c);var i=new E(t,n),u=new I(t,i,e,b.DYNAMIC);return o._interceptor.intercept(u),u.returnValue}},t.prototype.set=function(t,e,n,r){var o=new T(t,e),i=new N(o,[n],b.DYNAMIC);return this._interceptor.intercept(i),Reflect.set(t,e,n,r)},t.prototype.defineProperty=function(t,e,n){return n.configurable=!0,Reflect.defineProperty(t,e,n)},t}(),M=function(){function t(){}return t.createProxy=function(t,e){var n=j.of(e,t);return n},t.createProxyES6=function(t){var e=new S(t),n=k.of(e);return n},t}(),V=function(){function n(e,n,r){void 0===r&&(r=t.MockBehavior.Loose),this.targetInstance=e,this.canOverrideTarget=n,this.behavior=r,this._id=this.generateId(),this._name=this.getNameOf(this.targetInstance)}return 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,"callBase",{get:function(){return this._callBase},set:function(t){this._callBase=t},enumerable:!0,configurable:!0}),n.prototype.generateId=function(){return"Mock<"+e.uniqueId()+">"},n.prototype.getNameOf=function(t){var n;if(e.isFunction(t))n=i.functionName(t);else if(e.isObject(t)){var r=t.constructor;n=i.functionName(r)}return n&&(n=n.trim()),n},n.prototype.verifyAll=function(){try{this._interceptor.verify()}catch(t){throw t}},n.prototype.reset=function(){this._interceptor.reset()},n}();!function(t){t[t.Continue=0]="Continue",t[t.Stop=1]="Stop"}(C||(C={}));var D,L=function(){function t(t){this.mock=t,this._actualInvocations=[],this._expectedCalls=[]}return Object.defineProperty(t.prototype,"behavior",{get:function(){return this.mock.behavior},enumerable:!0,configurable:!0}),t.prototype.addInvocation=function(t){this._actualInvocations.push(t)},t.prototype.removeInvocation=function(t){e.remove(this._actualInvocations,function(e){return e===t})},t.prototype.actualInvocations=function(){return this._actualInvocations},t.prototype.clearInvocations=function(){this._actualInvocations.splice(0,this._actualInvocations.length)},t.prototype.addExpectedCall=function(t){this._expectedCalls.push(t)},t.prototype.removeExpectedCall=function(t){e.filter(this._expectedCalls,function(e){return e.id!==t.id})},t.prototype.expectedCalls=function(){return this._expectedCalls},t.prototype.clearExpectedCalls=function(){this._expectedCalls.splice(0,this._expectedCalls.length)},t.prototype.reset=function(){this.clearInvocations(),this.clearExpectedCalls()},t}(),U=function(){function t(){}return t}(),F=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){return e.addInvocation(t),C.Continue},t}(),B=function(){function n(){}return n.prototype.handleIntercept=function(n,o,i){var u=o.expectedCalls().slice(),c=function(t){return t.matches(n)},a=e.filter(u,function(t){return c(t)});if(a.length>1&&(c=function(t){return!t.isInvoked&&t.matches(n)}),i.call=e.find(u,function(t){return c(t)}),null!=i.call)i.call.evaluatedSuccessfully();else if(o.behavior==t.MockBehavior.Strict)throw new s(r.NoSetup,n,"'"+n+"'");return C.Continue},n}(),R=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){this._ctx=e;var r=n.call;return null!=r?(r.execute(t),C.Stop):C.Continue},t}(),Y=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){return e.mock.callBase?(t.invokeBase(),C.Stop):C.Continue},t}(),H=function(){function t(){}return t.prototype.handleIntercept=function(t,e,n){return C.Continue},t}(),G=function(){function t(t){this._interceptorContext=new L(t)}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 U;t.invocationType=m.EXECUTE,e.some(this.interceptionStrategies(),function(e){return C.Stop===e.handleIntercept(t,n.interceptorContext,r)?!0:void 0})},t.prototype.removeInvocation=function(t){this._interceptorContext.removeInvocation(t)},t.prototype.addExpectedCall=function(t){this._interceptorContext.addExpectedCall(t)},t.prototype.verify=function(){for(var t=this._interceptorContext.expectedCalls(),n=e.filter(t,function(t){return t.isVerifiable}),r=0,o=n;r<o.length;r++){var i=o[r];this.verifyCallCount(i,i.expectedCallCount)}var u=e.filter(t,function(t){return t.isInSequence});this.verifyCallsOrder(u)},t.prototype.verifyCallCount=function(t,n){var r=this._interceptorContext.actualInvocations(),o=e.filter(r,function(e){return t.matches(e)}).length;n.verify(o)||this.throwVerifyCallCountException(t.setupCall,n)},t.prototype.throwVerifyCallCountException=function(t,e){var n=new s(r.CallCountVerificationFailed,t,e.failMessage(t));throw n},t.prototype.verifyCallsOrder=function(t){var e=this._interceptorContext.actualInvocations();this.checkCallOrderExpectations(t,e)},t.prototype.checkCallOrderExpectations=function(t,n){var r=function(r){for(var o=e.sum(r),i=0,u=0;u<r.length;u++)for(var c=t[u],a=r[u],s=1;a>=s;s++){var p=n[i++];if(!c.matches(p))return!1}return i===o},o=!1,i=function(e,n){if(!o)if(n===t.length)o=r(e);else for(var u=t[n].expectedCallCount.min;u<=t[n].expectedCallCount.max;u++)e[n]=u,i(e,n+1)};i([],0),o||this.throwVerifyCallOrderException()},t.prototype.throwVerifyCallOrderException=function(){var t=new s(r.CallOrderVerificationFailed,null);throw t},t.prototype.reset=function(){this._interceptorContext.reset()},t.prototype.interceptionStrategies=function(){var t=[new F,new B,new R,new Y,new H];return t},t}(),q=function(){function t(){}return Object.defineProperty(t.prototype,"interceptedCall",{get:function(){return this._interceptedCall},enumerable:!0,configurable:!0}),t.prototype.intercept=function(t){if(t.invocationType=m.SETUP,t.proxyType==b.DYNAMIC&&t.callType==l.UNKNOWN&&(t.callType=l.PROPERTY),this._interceptedCall)throw new s(r.MoreThanOneSetup,t,"'"+t+"'; setup should contain only one expression");this._interceptedCall=t},t.prototype.removeInvocation=function(t){this._interceptedCall&&this._interceptedCall===t&&(this._interceptedCall=void 0)},t}(),X=function(){function o(t,e,n,o){if(this.mock=t,this._setupExpression=e,this._callCount=0,this._id=this.generateId(),e(o),!n.interceptedCall)throw new s(r.InvalidSetup,this._setupExpression,"'"+this._setupExpression+"'");var i=n.interceptedCall,u=this.transformToMatchers(i.args);Object.defineProperty(u,"callee",{configurable:!0,enumerable:!0,writable:!1,value:i.args.callee}),i.args=u,this._setupCall=i}return o.ofStaticMock=function(t,e){var n=new q,r=M.createProxy(n,t.targetInstance),i=new o(t,e,n,r);return i},o.ofDynamicMock=function(t,e){var n=new q,r=M.createProxyES6(n),i=new o(t,e,n,r);return i},o.prototype.generateId=function(){return"MethodCall<"+e.uniqueId()+">"},o.prototype.transformToMatchers=function(t){var n=[];return e.each(t,function(t){if(e.isObject(t))if(e.isUndefined(t[p.IMATCH_MATCHES_NAME])||e.isUndefined(t[p.IMATCH_ID_NAME])||t[p.IMATCH_ID_NAME]!==p.IMATCH_ID_VALUE){var r=new d(function(e){return e===t});n.push(r)}else n.push(t);else{var r=new v(t);n.push(r)}}),n},Object.defineProperty(o.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"setupExpression",{get:function(){return this._setupExpression},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"setupCall",{get:function(){return this._setupCall},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isVerifiable",{get:function(){return this._isVerifiable},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isInSequence",{get:function(){return this._expectedCallType===t.ExpectedCallType.InSequence},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"expectedCallCount",{get:function(){return this._expectedCallCount},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isInvoked",{get:function(){return this._isInvoked},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"callCount",{get:function(){return this._callCount},enumerable:!0,configurable:!0}),o.prototype.evaluatedSuccessfully=function(){this._evaluatedSuccessfully=!0},o.prototype.matches=function(t){var n=!1;return this._setupCall.property&&t&&t.property&&this._setupCall.property.name===t.property.name&&(t.proxyType==b.DYNAMIC&&t.callType==l.UNKNOWN&&t.invocationType==m.EXECUTE&&(t.callType=this._setupCall.callType),this._setupCall.args.length>=t.args.length&&(n=!0,e.each(this._setupCall.args,function(e,r){var o=e,i=t.args[r];n&&!o.___matches(i)&&(n=!1)}))),n},o.prototype.execute=function(t){if(this._isInvoked=!0,null!=this._setupCallback&&this._setupCallback.apply(this,t.args),null!=this._thrownException)throw this._thrownException;this._callCount++},o.prototype.verifiable=function(e,r){void 0===e&&(e=n.atLeastOnce()),void 0===r&&(r=t.ExpectedCallType.InAnyOrder),this._isVerifiable=!0,this._expectedCallCount=e,this._expectedCallType=r},o}(),W=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),K=function(t){function e(e,n,r,o){var i=t.call(this,e,n,r,o)||this;return i._overrideTarget=e.canOverrideTarget,i}return W(e,t),e.ofStaticMock=function(t,n){var r=new q,o=M.createProxy(r,t.targetInstance),i=new e(t,n,r,o);return i},e.ofDynamicMock=function(t,n){var r=new q,o=M.createProxyES6(r),i=new e(t,n,r,o);return i},e.prototype.execute=function(e){t.prototype.execute.call(this,e),this._callBase?e.invokeBase():this.hasReturnValue&&(e.returnValue=this._returnValueFunc.apply(this,e.args),e.property.desc={value:this.setupCall.property.desc&&this.setupCall.property.desc.value})},e.prototype.callback=function(t){return this._setupCallback=t,this},e.prototype["throws"]=function(t){return this._thrownException=t,this},e.prototype.returns=function(t){if(this._returnValueFunc=t,this.hasReturnValue=!0,this._overrideTarget){var e=this.mock.targetInstance,n=this.setupCall.property.name,r=this.setupCall.property.desc;r&&(r.configurable=!0,r.enumerable=!0,r.value=this._returnValueFunc,Object.defineProperty(e,n,r))}return this},e.prototype.callBase=function(){return this._callBase=!0,this},e}(X),z=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),J=function(t){function n(e,n,r){var o=t.call(this,e,n,r)||this;return o._interceptor=new G(o),o._proxy=M.createProxy(o._interceptor,e),o}return z(n,t),n.ofInstance=function(t,e){t=n.cloneDeep(t);var r=new n(t,!0,e);return r},n.ofGlobalInstance=function(t,e){var r=new n(t,!1,e);return r},n.ofType=function(t,e,r){var o=i.conthunktor(t,r),u=new n(o,!0,e);return u},n.cloneDeep=function(t){var n=t;if(!e.isFunction(t)){var r=function(t){return j.isProxy(t)?t:void 0};n=e.cloneDeepWith(t,r)}return n},n.prototype.setup=function(t){var e=K.ofStaticMock(this,t);return this._interceptor.addExpectedCall(e),e},n.prototype.verify=function(t,e){var n=X.ofStaticMock(this,t);this._interceptor.addExpectedCall(n);try{this._interceptor.verifyCallCount(n,e)}catch(r){throw r}},n}(V),Q=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Z=function(t){function e(e,n,r){var o=t.call(this,{},n,r)||this;return e&&(o._name=e),o._interceptor=new G(o),o._proxy=M.createProxyES6(o._interceptor),o}return Q(e,t),e.ofType=function(t,n){var r=new e(t,!0,n);return r},e.prototype.setup=function(t){var e=K.ofDynamicMock(this,t);return this._interceptor.addExpectedCall(e),e},e.prototype.verify=function(t,e){var n=X.ofDynamicMock(this,t);this._interceptor.addExpectedCall(n);try{this._interceptor.verifyCallCount(n,e)}catch(r){throw r}},e}(V),$=function(){function e(){}return e.ofInstance=function(e,n){void 0===n&&(n=t.MockBehavior.Loose);var r=J.ofInstance(e,n);return r},e.ofType=function(n,r){void 0===r&&(r=t.MockBehavior.Loose);for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];var u;return u=n?e.ofType2(n,o,r):Z.ofType(void 0,r)},e.ofType2=function(e,n,r){void 0===r&&(r=t.MockBehavior.Loose);var o=J.ofType(e,r,n);return o},e}(),tt=function(){function t(){}return t.isValue=function(t){var e=new v(t);return e},t.isAnyObject=function(t){var e=new f(t);return e},t.isAny=function(){var t=new h;return t},t.isAnyString=function(){var t=new y;return t},t.isAnyNumber=function(){var t=new _;return t},t.is=function(t){var e=new d(t);return e},t}();!function(t){t[t.Class=0]="Class",t[t.Function=1]="Function",t[t.Value=2]="Value"}(D||(D={}));var et=function(){function t(t,e,n,r){this.mock=t,this._name=e,this._type=n,this.container=r,this._name||(this._name=t.name)}return 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(t){this.mock.callBase=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),t.prototype.setup=function(t){return this.mock.setup(t)},t.prototype.verify=function(t,e){this.mock.verify(t,e)},t.prototype.verifyAll=function(){this.mock.verifyAll()},t.prototype.reset=function(){this.mock.reset()},t}(),nt=function(){function n(){}return n.ofInstance=function(n,r,o,i){void 0===o&&(o=window),void 0===i&&(i=t.MockBehavior.Loose);var u=J.ofGlobalInstance(n,i),c=e.isFunction(n)?D.Function:D.Value;return new et(u,r,c,o)},n.ofType=function(e,n,r){void 0===n&&(n=window),void 0===r&&(r=t.MockBehavior.Loose);var o=new e,i=J.ofInstance(o,r);return new et(i,void 0,D.Class,n)},n.ofType2=function(e,n,r){void 0===n&&(n=window),void 0===r&&(r=t.MockBehavior.Loose);var o=Z.ofType(e,r);return new et(o,void 0,D.Class,n)},n}(),rt=function(){function t(t){this._args=t}return t.prototype["with"]=function(t){var n={};try{e.each(this._args,function(t){var i=o.getOwnAndPrototypeEnumerablesAndNonenumerables(t.container),u=e.find(i,function(e){return e.name===t.name});if(u){n[t.name]=u.desc;var c={};switch(t.type){case D.Class:c.value=function(){return t.mock.object};break;case D.Function:c.value=t.mock.object;break;case D.Value:c.get=function(){return t.mock.object};break;default:throw new s(r.UnknownGlobalType,t,"unknown global type: "+t.type)}try{Object.defineProperty(t.container,t.name,c)}catch(a){console.log("1: "+a)}}}),t.apply(this,this._args)}catch(i){console.log("2: "+i)}finally{e.each(this._args,function(t){var e=n[t.name];if(e){switch(t.type){case D.Class:break;case D.Function:break;case D.Value:e.configurable=!0}try{Object.defineProperty(t.container,t.name,e)}catch(r){console.log("3: "+r)}}})}},t}(),ot=function(){function t(){}return t.using=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new rt(t);return n},t}();t.Mock=$,t.It=tt,t.Times=n,t.GlobalMock=nt,t.GlobalScope=ot,t.MockException=s,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -379,3 +379,12 @@ // Generated by dts-bundle v0.7.2

declare module 'typemoq/Proxy/ICallContext' {
import { IPropertyInfo } from "typemoq/Proxy/Invocation";
import { IPropertyInfo, InvocationType } from "typemoq/Proxy/Invocation";
export enum CallType {
UNKNOWN = 0,
PROPERTY = 1,
FUNCTION = 2,
}
export enum ProxyType {
STATIC = 0,
DYNAMIC = 1,
}
export interface ICallContext {

@@ -386,2 +395,5 @@ args: IArguments;

invokeBase(): void;
invocationType: InvocationType;
callType: CallType;
proxyType: ProxyType;
}

@@ -400,5 +412,14 @@ }

import * as common from "typemoq/Common/_all";
import { ICallContext } from "typemoq/Proxy/ICallContext";
import { ICallContext, CallType, ProxyType } from "typemoq/Proxy/ICallContext";
export enum InvocationType {
NONE = 0,
SETUP = 1,
EXECUTE = 2,
}
export abstract class BaseInvocation implements ICallContext {
readonly proxyType: ProxyType;
callType: CallType;
returnValue: any;
invocationType: InvocationType;
constructor(proxyType: ProxyType, callType: CallType);
abstract args: IArguments;

@@ -409,3 +430,3 @@ readonly abstract property: IPropertyInfo;

export class MethodInvocation extends BaseInvocation {
constructor(_that: Object, _property: MethodInfo, _args?: IArguments);
constructor(_that: Object, _property: MethodInfo, _args?: IArguments, proxyType?: ProxyType, callType?: CallType);
args: IArguments;

@@ -418,3 +439,3 @@ readonly property: IPropertyInfo;

readonly value: any;
constructor(_property: IPropertyInfo, value: any);
constructor(_property: IPropertyInfo, value: any, proxyType?: ProxyType, callType?: CallType);
args: IArguments;

@@ -425,4 +446,7 @@ readonly property: IPropertyInfo;

}
export class DynamicGetInvocation extends ValueGetterInvocation {
constructor(property: IPropertyInfo, value: any);
}
export class ValueSetterInvocation extends BaseInvocation {
constructor(_property: IPropertyInfo, _args: IArguments);
constructor(_property: IPropertyInfo, _args: IArguments, proxyType?: ProxyType, callType?: CallType);
args: IArguments;

@@ -434,3 +458,3 @@ readonly property: IPropertyInfo;

export class MethodGetterInvocation extends BaseInvocation {
constructor(_property: IPropertyInfo, _getter: () => any);
constructor(_property: IPropertyInfo, _getter: () => any, proxyType?: ProxyType, callType?: CallType);
args: IArguments;

@@ -442,3 +466,3 @@ readonly property: IPropertyInfo;

export class MethodSetterInvocation extends BaseInvocation {
constructor(_property: IPropertyInfo, _setter: (v: any) => void, _args: IArguments);
constructor(_property: IPropertyInfo, _setter: (v: any) => void, _args: IArguments, proxyType?: ProxyType, callType?: CallType);
args: IArguments;

@@ -445,0 +469,0 @@ readonly property: IPropertyInfo;

@@ -241,3 +241,3 @@ (function (global, factory) {

var match = false;
if (this._ctor.prototype === object.constructor.prototype)
if (object && object.constructor.prototype == this._ctor.prototype)
match = true;

@@ -303,3 +303,3 @@ return match;

var match = false;
if (this._pred(object))
if (object && this._pred(object))
match = true;

@@ -333,2 +333,14 @@ return match;

var CallType;
(function (CallType) {
CallType[CallType["UNKNOWN"] = 0] = "UNKNOWN";
CallType[CallType["PROPERTY"] = 1] = "PROPERTY";
CallType[CallType["FUNCTION"] = 2] = "FUNCTION";
})(CallType || (CallType = {}));
var ProxyType;
(function (ProxyType) {
ProxyType[ProxyType["STATIC"] = 0] = "STATIC";
ProxyType[ProxyType["DYNAMIC"] = 1] = "DYNAMIC";
})(ProxyType || (ProxyType = {}));
var __extends$3 = (undefined && undefined.__extends) || (function () {

@@ -344,4 +356,13 @@ var extendStatics = Object.setPrototypeOf ||

})();
var InvocationType;
(function (InvocationType) {
InvocationType[InvocationType["NONE"] = 0] = "NONE";
InvocationType[InvocationType["SETUP"] = 1] = "SETUP";
InvocationType[InvocationType["EXECUTE"] = 2] = "EXECUTE";
})(InvocationType || (InvocationType = {}));
var BaseInvocation = (function () {
function BaseInvocation() {
function BaseInvocation(proxyType, callType) {
this.proxyType = proxyType;
this.callType = callType;
this.invocationType = InvocationType.NONE;
}

@@ -352,4 +373,6 @@ return BaseInvocation;

__extends$3(MethodInvocation, _super);
function MethodInvocation(_that, _property, _args) {
var _this = _super.call(this) || this;
function MethodInvocation(_that, _property, _args, proxyType, callType) {
if (proxyType === void 0) { proxyType = ProxyType.STATIC; }
if (callType === void 0) { callType = CallType.FUNCTION; }
var _this = _super.call(this, proxyType, callType) || this;
_this._that = _that;

@@ -387,4 +410,6 @@ _this._property = _property;

__extends$3(ValueGetterInvocation, _super);
function ValueGetterInvocation(_property, value) {
var _this = _super.call(this) || this;
function ValueGetterInvocation(_property, value, proxyType, callType) {
if (proxyType === void 0) { proxyType = ProxyType.STATIC; }
if (callType === void 0) { callType = CallType.PROPERTY; }
var _this = _super.call(this, proxyType, callType) || this;
_this._property = _property;

@@ -419,6 +444,17 @@ _this.value = value;

}(BaseInvocation));
var DynamicGetInvocation = (function (_super) {
__extends$3(DynamicGetInvocation, _super);
function DynamicGetInvocation(property, value) {
var _this = _super.call(this, property, value, ProxyType.DYNAMIC, CallType.UNKNOWN) || this;
_this.returnValue = value;
return _this;
}
return DynamicGetInvocation;
}(ValueGetterInvocation));
var ValueSetterInvocation = (function (_super) {
__extends$3(ValueSetterInvocation, _super);
function ValueSetterInvocation(_property, _args) {
var _this = _super.call(this) || this;
function ValueSetterInvocation(_property, _args, proxyType, callType) {
if (proxyType === void 0) { proxyType = ProxyType.STATIC; }
if (callType === void 0) { callType = CallType.PROPERTY; }
var _this = _super.call(this, proxyType, callType) || this;
_this._property = _property;

@@ -451,4 +487,6 @@ _this._args = _args;

__extends$3(MethodGetterInvocation, _super);
function MethodGetterInvocation(_property, _getter) {
var _this = _super.call(this) || this;
function MethodGetterInvocation(_property, _getter, proxyType, callType) {
if (proxyType === void 0) { proxyType = ProxyType.STATIC; }
if (callType === void 0) { callType = CallType.FUNCTION; }
var _this = _super.call(this, proxyType, callType) || this;
_this._property = _property;

@@ -484,4 +522,6 @@ _this._getter = _getter;

__extends$3(MethodSetterInvocation, _super);
function MethodSetterInvocation(_property, _setter, _args) {
var _this = _super.call(this) || this;
function MethodSetterInvocation(_property, _setter, _args, proxyType, callType) {
if (proxyType === void 0) { proxyType = ProxyType.STATIC; }
if (callType === void 0) { callType = CallType.FUNCTION; }
var _this = _super.call(this, proxyType, callType) || this;
_this._property = _property;

@@ -714,3 +754,3 @@ _this._setter = _setter;

var method = new MethodInfo(target, funcName);
var invocation = new MethodInvocation(target, method, argArray);
var invocation = new MethodInvocation(target, method, argArray, ProxyType.DYNAMIC);
this._interceptor.intercept(invocation);

@@ -722,9 +762,9 @@ return invocation.returnValue;

var propValue = target[p];
var method = new PropertyInfo(target, p, { value: true });
var valueInvocation = new ValueGetterInvocation(method, propValue);
this._interceptor.intercept(valueInvocation);
var method = new PropertyInfo(target, p);
var invocation = new DynamicGetInvocation(method, propValue);
this._interceptor.intercept(invocation);
if (!_.isFunction(propValue) &&
!_.isUndefined(valueInvocation.returnValue) &&
valueInvocation.property.desc && valueInvocation.property.desc.value)
return valueInvocation.returnValue;
invocation.callType == CallType.PROPERTY &&
invocation.property.desc)
return invocation.returnValue;
else

@@ -736,5 +776,5 @@ return function () {

}
_this._interceptor.removeInvocation(valueInvocation);
_this._interceptor.removeInvocation(invocation);
var method = new MethodInfo(target, p);
var methodInvocation = new MethodInvocation(target, method, args);
var methodInvocation = new MethodInvocation(target, method, args, ProxyType.DYNAMIC);
_this._interceptor.intercept(methodInvocation);

@@ -746,3 +786,3 @@ return methodInvocation.returnValue;

var method = new PropertyInfo(target, p);
var invocation = new ValueSetterInvocation(method, [value]);
var invocation = new ValueSetterInvocation(method, [value], ProxyType.DYNAMIC);
this._interceptor.intercept(invocation);

@@ -954,2 +994,3 @@ return Reflect.set(target, p, value, receiver);

var localCtx = new CurrentInterceptContext();
invocation.invocationType = InvocationType.EXECUTE;
_.some(this.interceptionStrategies(), function (strategy) {

@@ -1051,2 +1092,6 @@ if (InterceptionAction.Stop === strategy.handleIntercept(invocation, _this.interceptorContext, localCtx)) {

InterceptorSetup.prototype.intercept = function (invocation) {
invocation.invocationType = InvocationType.SETUP;
if (invocation.proxyType == ProxyType.DYNAMIC &&
invocation.callType == CallType.UNKNOWN)
invocation.callType = CallType.PROPERTY;
if (this._interceptedCall) {

@@ -1165,5 +1210,9 @@ throw new MockException(MockExceptionReason.MoreThanOneSetup, invocation, "'" + invocation + "'; setup should contain only one expression");

this._setupCall.property.name === call.property.name) {
if (this._setupCall.args.length === call.args.length) {
if (call.proxyType == ProxyType.DYNAMIC &&
call.callType == CallType.UNKNOWN &&
call.invocationType == InvocationType.EXECUTE)
call.callType = this._setupCall.callType;
if (this._setupCall.args.length >= call.args.length) {
match = true;
_.each(this.setupCall.args, function (x, index) {
_.each(this._setupCall.args, function (x, index) {
var setupArg = x;

@@ -1170,0 +1219,0 @@ var callArg = call.args[index];

{
"name": "typemoq",
"version": "1.3.1",
"version": "1.4.0",
"description": "A simple mocking library for TypeScript",

@@ -5,0 +5,0 @@ "author": "Florin Nitoi <florin.nitoi@gmail.com>",

@@ -102,12 +102,12 @@ TypeMoq [![build badge](https://travis-ci.org/florinn/typemoq.svg?branch=master)](https://travis-ci.org/florinn/typemoq)

---- | ----
*TypeMoq.Mock* | Used for creating 'regular' mocks (see [Create mocks](#create_mocks) and [Setup mocks](#setup_mocks))
*TypeMoq.MockBehavior* | Used to specify how the mock should act when no expectations are defined (see [Control mock behavior](#mock_behavior))
*TypeMoq.It* | Helper for matching arguments (see [Setup mocks](#setup_mocks) and [Verify expectations](#verify_expectations))
*TypeMoq.Times* | Helper for performing verification (see [Verify expectations](#verify_expectations))
*TypeMoq.GlobalMock* | Used to create 'global' mocks corresponding to global objects (see [Create global mocks](#create_global_mocks))
*TypeMoq.GlobalScope* | Used to create an execution context that makes use of any specified 'global' mocks (see [Auto sandbox global mocks](#auto_sandbox))
*TypeMoq.Mock* | Used for creating 'regular' mocks (see [Create mocks](#create-mocks) and [Setup mocks](#setup-mocks))
*TypeMoq.MockBehavior* | Used to specify how the mock should act when no expectations are defined (see [Control mock behavior](#control-mock-behavior))
*TypeMoq.It* | Helper for matching arguments (see [Setup mocks](#setup-mocks) and [Verify expectations](#verify-expectations))
*TypeMoq.Times* | Helper for performing verification (see [Verify expectations](#verify-expectations))
*TypeMoq.GlobalMock* | Used to create 'global' mocks corresponding to global objects (see [Create global mocks](#create-global-mocks))
*TypeMoq.GlobalScope* | Used to create an execution context that makes use of any specified 'global' mocks (see [Auto sandbox global mocks](#auto-sandbox-global-mocks))
*TypeMoq.MockException* | Exception thrown internally containing debug info
###<a name="create_mocks"></a> Create mocks
### Create mocks

@@ -250,3 +250,3 @@ #### Static mocks

* Properties can be set to return any falsy value except `undefined`
* Properties can be set to return any falsy value

@@ -268,3 +268,3 @@ ```typescript

expect(mock.object.anyValue).to.be.a("function");
expect(mock.object.anyValue).to.be.undefined;
```

@@ -277,3 +277,3 @@

###<a name="setup_mocks"></a> Setup mocks
### Setup mocks

@@ -486,3 +486,3 @@ Mocks allow to match functions, methods and properties and setup return callbacks or exceptions to throw.

In the latter case, when there are no more recorded setups left to play, the mock starts returning default values or raises MockException if `MockBehavior.Strict` (see [Control mock behavior](#mock_behavior)).
In the latter case, when there are no more recorded setups left to play, the mock starts returning default values or raises MockException if `MockBehavior.Strict` (see [Control mock behavior](#control-mock-behavior)).

@@ -495,3 +495,3 @@

###<a name="mock_behavior"></a> Control mock behavior
### Control mock behavior

@@ -519,3 +519,3 @@ ##### Using MockBehavior

###<a name="verify_expectations"></a> Verify expectations
### Verify expectations

@@ -649,3 +649,3 @@ Expectations can be verified either one by one or all at once by marking matchers as verifiable.

###<a name="create_global_mocks"></a> Create global mocks
### Create global mocks

@@ -733,3 +733,3 @@ #### Static global mocks

###<a name="auto_sandbox"></a> Auto sandbox global mocks
### Auto sandbox global mocks

@@ -736,0 +736,0 @@ Replacing and restoring global class types and objects is done automagically by combining global mocks with global scopes.

@@ -18,2 +18,4 @@ import * as _ from "lodash";

let localCtx = new CurrentInterceptContext();
invocation.invocationType = all.InvocationType.EXECUTE;

@@ -20,0 +22,0 @@ _.some(this.interceptionStrategies(), (strategy: IInterceptStrategy<T>) => {

@@ -9,2 +9,8 @@ import * as all from "./_all";

intercept(invocation: all.ICallContext) {
invocation.invocationType = all.InvocationType.SETUP;
if (invocation.proxyType == all.ProxyType.DYNAMIC &&
invocation.callType == all.CallType.UNKNOWN)
invocation.callType = all.CallType.PROPERTY;
if (this._interceptedCall) {

@@ -11,0 +17,0 @@ throw new all.MockException(all.MockExceptionReason.MoreThanOneSetup,

@@ -15,3 +15,3 @@ import * as _ from "lodash";

let match = false;
if (this._ctor.prototype === object.constructor.prototype)
if (object && object.constructor.prototype == this._ctor.prototype)
match = true;

@@ -18,0 +18,0 @@ return match;

@@ -14,3 +14,3 @@ import * as common from "../Common/_all";

let match = false;
if (this._pred(<T>object))
if (object && this._pred(<T>object))
match = true;

@@ -17,0 +17,0 @@ return match;

@@ -109,7 +109,10 @@ import * as _ from "lodash";

if (this._setupCall.args.length === call.args.length) {
if (call.proxyType == all.ProxyType.DYNAMIC &&
call.callType == all.CallType.UNKNOWN &&
call.invocationType == all.InvocationType.EXECUTE)
call.callType = this._setupCall.callType;
if (this._setupCall.args.length >= call.args.length) {
match = true;
_.each(this.setupCall.args, (x: any, index: number) => {
_.each(this._setupCall.args, (x: any, index: number) => {
let setupArg = <all.IMatch>x;

@@ -121,3 +124,2 @@ let callArg = call.args[index];

});
}

@@ -124,0 +126,0 @@ }

@@ -1,3 +0,11 @@

import { IPropertyInfo } from "./Invocation";
import { IPropertyInfo, InvocationType } from "./Invocation";
export enum CallType {
UNKNOWN, PROPERTY, FUNCTION
}
export enum ProxyType {
STATIC, DYNAMIC
}
export interface ICallContext {

@@ -8,2 +16,5 @@ args: IArguments;

invokeBase(): void;
invocationType: InvocationType;
callType: CallType;
proxyType: ProxyType;
}
import * as _ from "lodash";
import * as common from "../Common/_all";
import { ICallContext } from "./ICallContext";
import { ICallContext, CallType, ProxyType } from "./ICallContext";
export enum InvocationType {
NONE, SETUP, EXECUTE
}
export abstract class BaseInvocation implements ICallContext {
returnValue: any;
invocationType = InvocationType.NONE;
constructor(public readonly proxyType: ProxyType, public callType: CallType) {
}
abstract get args(): IArguments;

@@ -20,4 +29,6 @@ abstract set args(value: IArguments);

private readonly _property: MethodInfo,
private _args?: IArguments) {
super();
private _args?: IArguments,
proxyType = ProxyType.STATIC,
callType = CallType.FUNCTION) {
super(proxyType, callType);
}

@@ -48,4 +59,6 @@

private readonly _property: IPropertyInfo,
readonly value: any) {
super();
readonly value: any,
proxyType = ProxyType.STATIC,
callType = CallType.PROPERTY) {
super(proxyType, callType);
this.returnValue = value;

@@ -74,7 +87,18 @@ }

export class DynamicGetInvocation extends ValueGetterInvocation {
constructor(
property: IPropertyInfo,
value: any) {
super(property, value, ProxyType.DYNAMIC, CallType.UNKNOWN);
this.returnValue = value;
}
}
export class ValueSetterInvocation extends BaseInvocation {
constructor(
private readonly _property: IPropertyInfo,
private _args: IArguments) {
super();
private _args: IArguments,
proxyType = ProxyType.STATIC,
callType = CallType.PROPERTY) {
super(proxyType, callType);
}

@@ -101,4 +125,6 @@

private readonly _property: IPropertyInfo,
private readonly _getter: () => any) {
super();
private readonly _getter: () => any,
proxyType = ProxyType.STATIC,
callType = CallType.FUNCTION) {
super(proxyType, callType);
}

@@ -130,4 +156,6 @@

private readonly _setter: (v: any) => void,
private _args: IArguments) {
super();
private _args: IArguments,
proxyType = ProxyType.STATIC,
callType = CallType.FUNCTION) {
super(proxyType, callType);
}

@@ -192,2 +220,2 @@

desc?: common.PropDescriptor;
}
}
import * as _ from "lodash";
import * as common from "../Common/_all";
import { ICallContext } from "./ICallContext";
import { ICallContext, ProxyType, CallType } from "./ICallContext";
import { ICallInterceptor } from "./ICallInterceptor";
import { PropertyInfo, MethodInfo, MethodInvocation, MethodGetterInvocation, MethodSetterInvocation, ValueGetterInvocation, ValueSetterInvocation } from "./Invocation";
import * as inv from "./Invocation";
import { IProxyHandler, PropKey } from "./IProxyHandler";

@@ -16,4 +16,4 @@

let funcName = common.Utils.functionName(target);
let method = new MethodInfo(target, funcName);
let invocation: ICallContext = new MethodInvocation(target, method, argArray);
let method = new inv.MethodInfo(target, funcName);
let invocation: ICallContext = new inv.MethodInvocation(target, method, argArray, ProxyType.DYNAMIC);
this._interceptor.intercept(invocation);

@@ -27,18 +27,19 @@

let propValue = (<any>target)[p];
let method = new PropertyInfo(target, <string>p, { value: true });
let valueInvocation = new ValueGetterInvocation(method, propValue);
this._interceptor.intercept(valueInvocation);
let method = new inv.PropertyInfo(target, <string>p);
let invocation = new inv.DynamicGetInvocation(method, propValue);
this._interceptor.intercept(invocation);
if (!_.isFunction(propValue) &&
!_.isUndefined(valueInvocation.returnValue) &&
valueInvocation.property.desc && valueInvocation.property.desc.value) // value getter invocation at execution time
invocation.callType == CallType.PROPERTY &&
invocation.property.desc) // value getter invocation at execution time
return valueInvocation.returnValue;
return invocation.returnValue;
else
return (...args: any[]) => {
this._interceptor.removeInvocation(valueInvocation);
this._interceptor.removeInvocation(invocation);
let method = new MethodInfo(target, <string>p);
let methodInvocation = new MethodInvocation(target, method, <any>args);
let method = new inv.MethodInfo(target, <string>p);
let methodInvocation = new inv.MethodInvocation(target, method, <any>args, ProxyType.DYNAMIC);
this._interceptor.intercept(methodInvocation);

@@ -52,4 +53,4 @@

let method = new PropertyInfo(target, <string>p);
let invocation: ICallContext = new ValueSetterInvocation(method, <any>[value]);
let method = new inv.PropertyInfo(target, <string>p);
let invocation: ICallContext = new inv.ValueSetterInvocation(method, <any>[value], ProxyType.DYNAMIC);
this._interceptor.intercept(invocation);

@@ -56,0 +57,0 @@

@@ -217,2 +217,26 @@ import { Utils } from "./Utils";

export class APromise {
public doOperation<T>(
op: () => void,
processData: (data: string) => boolean,
processError: (err: string) => boolean,
timeout: number = 2000
): Promise<T> {
return new Promise((resolve, reject) => {
reject("Fail!");
});
}
}
export class AnotherPromise {
constructor(private myPromise: APromise) { }
public doSomething(): Promise<void> {
return this.myPromise.doOperation<void>(
() => { },
(x) => true,
(x) => true
);
}
}
export class XMLHttpRequest {

@@ -219,0 +243,0 @@ open(method: string, url: string, async?: boolean, user?: string, password?: string): void { };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc