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.2.1 to 1.3.0

7

CHANGELOG.md

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

v1.3.0 / 2017-03-09
===================
* enable static mocks to verify any inner calls inside a method call when callBase is true #51
* enable dynamic mocks to return falsy values (except 'undefined') from properties #50
* various doc improvements
v1.2.1 / 2017-02-28

@@ -2,0 +9,0 @@ ===================

2

dist/typemoq-min.js

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

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

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

// Generated by dts-bundle v0.6.1
// Generated by dts-bundle v0.7.2

@@ -168,2 +168,3 @@ declare module 'typemoq' {

export * from "typemoq/Proxy/ProxyES5";
export * from "typemoq/Proxy/ProxyES6";
export * from "typemoq/Proxy/ProxyFactory";

@@ -294,2 +295,3 @@ }

static conthunktor<U>(ctor: CtorWithArgs<U>, args: any[]): U;
static clone(target: Object, source: Object): void;
}

@@ -382,40 +384,41 @@ }

import { ICallContext } from "typemoq/Proxy/ICallContext";
export class MethodInvocation implements ICallContext {
export abstract class BaseInvocation implements ICallContext {
returnValue: any;
constructor(_property: MethodInfo, _args?: IArguments);
abstract args: IArguments;
readonly abstract property: IPropertyInfo;
abstract invokeBase(): void;
}
export class MethodInvocation extends BaseInvocation {
constructor(_that: Object, _property: MethodInfo, _args?: IArguments);
args: IArguments;
readonly property: PropertyInfo;
readonly property: IPropertyInfo;
invokeBase(): void;
toString(): string;
}
export class ValueGetterInvocation implements ICallContext {
export class ValueGetterInvocation extends BaseInvocation {
readonly value: any;
returnValue: any;
constructor(_property: PropertyInfo, value: any);
constructor(_property: IPropertyInfo, value: any);
args: IArguments;
readonly property: PropertyInfo;
readonly property: IPropertyInfo;
invokeBase(): void;
toString(): string;
}
export class ValueSetterInvocation implements ICallContext {
returnValue: any;
constructor(_property: PropertyInfo, _args: IArguments);
export class ValueSetterInvocation extends BaseInvocation {
constructor(_property: IPropertyInfo, _args: IArguments);
args: IArguments;
readonly property: PropertyInfo;
readonly property: IPropertyInfo;
invokeBase(): void;
toString(): string;
}
export class MethodGetterInvocation implements ICallContext {
returnValue: any;
constructor(_property: PropertyInfo, _getter: () => any);
export class MethodGetterInvocation extends BaseInvocation {
constructor(_property: IPropertyInfo, _getter: () => any);
args: IArguments;
readonly property: PropertyInfo;
readonly property: IPropertyInfo;
invokeBase(): void;
toString(): string;
}
export class MethodSetterInvocation implements ICallContext {
returnValue: any;
constructor(_property: PropertyInfo, _setter: (v: any) => void, _args: IArguments);
export class MethodSetterInvocation extends BaseInvocation {
constructor(_property: IPropertyInfo, _setter: (v: any) => void, _args: IArguments);
args: IArguments;
readonly property: PropertyInfo;
readonly property: IPropertyInfo;
invokeBase(): void;

@@ -481,2 +484,10 @@ toString(): string;

declare module 'typemoq/Proxy/ProxyES6' {
import { IProxy } from "typemoq/Proxy/IProxy";
export class ProxyES6<T> implements IProxy {
readonly ___id: string;
static of<U>(handler: ProxyHandler<U>): ProxyES6<U>;
}
}
declare module 'typemoq/Proxy/ProxyFactory' {

@@ -483,0 +494,0 @@ import { ICallInterceptor } from "typemoq/Proxy/ICallInterceptor";

@@ -146,10 +146,22 @@ (function (global, factory) {

};
Utils.clone = function (target, source) {
var sourceProps = PropertyRetriever.getOwnAndPrototypeEnumerablesAndNonenumerables(source);
for (var _i = 0, sourceProps_1 = sourceProps; _i < sourceProps_1.length; _i++) {
var p = sourceProps_1[_i];
Object.defineProperty(target, p.name, p.desc);
}
};
return Utils;
}());
var __extends$1 = (undefined && undefined.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends$1 = (undefined && undefined.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var Exception = (function (_super) {

@@ -170,7 +182,12 @@ __extends$1(Exception, _super);

var __extends$2 = (undefined && undefined.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends$2 = (undefined && undefined.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var MockExceptionReason;

@@ -316,7 +333,26 @@ (function (MockExceptionReason) {

var MethodInvocation = (function () {
function MethodInvocation(_property, _args) {
this._property = _property;
this._args = _args;
var __extends$3 = (undefined && undefined.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var BaseInvocation = (function () {
function BaseInvocation() {
}
return BaseInvocation;
}());
var MethodInvocation = (function (_super) {
__extends$3(MethodInvocation, _super);
function MethodInvocation(_that, _property, _args) {
var _this = _super.call(this) || this;
_this._that = _that;
_this._property = _property;
_this._args = _args;
return _this;
}
Object.defineProperty(MethodInvocation.prototype, "args", {

@@ -334,3 +370,8 @@ get: function () { return this._args || { length: 0, callee: null }; },

MethodInvocation.prototype.invokeBase = function () {
this.returnValue = this._property.toFunc.apply(this._property.obj, this._args);
var thatClone = {};
if (this._that)
Utils.clone(thatClone, this._that);
else
thatClone = this._property.obj;
this.returnValue = this._property.toFunc.apply(thatClone, this._args);
};

@@ -342,8 +383,11 @@ MethodInvocation.prototype.toString = function () {

return MethodInvocation;
}());
var ValueGetterInvocation = (function () {
}(BaseInvocation));
var ValueGetterInvocation = (function (_super) {
__extends$3(ValueGetterInvocation, _super);
function ValueGetterInvocation(_property, value) {
this._property = _property;
this.value = value;
this.returnValue = value;
var _this = _super.call(this) || this;
_this._property = _property;
_this.value = value;
_this.returnValue = value;
return _this;
}

@@ -353,3 +397,3 @@ Object.defineProperty(ValueGetterInvocation.prototype, "args", {

var args = [];
Object.defineProperty(args, "callee", { configurable: false, enumerable: true, writable: false, value: null });
Object.defineProperty(args, "callee", { configurable: true, enumerable: true, writable: false, value: null });
return args;

@@ -374,7 +418,10 @@ },

return ValueGetterInvocation;
}());
var ValueSetterInvocation = (function () {
}(BaseInvocation));
var ValueSetterInvocation = (function (_super) {
__extends$3(ValueSetterInvocation, _super);
function ValueSetterInvocation(_property, _args) {
this._property = _property;
this._args = _args;
var _this = _super.call(this) || this;
_this._property = _property;
_this._args = _args;
return _this;
}

@@ -401,7 +448,10 @@ Object.defineProperty(ValueSetterInvocation.prototype, "args", {

return ValueSetterInvocation;
}());
var MethodGetterInvocation = (function () {
}(BaseInvocation));
var MethodGetterInvocation = (function (_super) {
__extends$3(MethodGetterInvocation, _super);
function MethodGetterInvocation(_property, _getter) {
this._property = _property;
this._getter = _getter;
var _this = _super.call(this) || this;
_this._property = _property;
_this._getter = _getter;
return _this;
}

@@ -411,3 +461,3 @@ Object.defineProperty(MethodGetterInvocation.prototype, "args", {

var args = [];
Object.defineProperty(args, "callee", { configurable: false, enumerable: true, writable: false, value: null });
Object.defineProperty(args, "callee", { configurable: true, enumerable: true, writable: false, value: null });
return args;

@@ -432,8 +482,11 @@ },

return MethodGetterInvocation;
}());
var MethodSetterInvocation = (function () {
}(BaseInvocation));
var MethodSetterInvocation = (function (_super) {
__extends$3(MethodSetterInvocation, _super);
function MethodSetterInvocation(_property, _setter, _args) {
this._property = _property;
this._setter = _setter;
this._args = _args;
var _this = _super.call(this) || this;
_this._property = _property;
_this._setter = _setter;
_this._args = _args;
return _this;
}

@@ -460,3 +513,3 @@ Object.defineProperty(MethodSetterInvocation.prototype, "args", {

return MethodSetterInvocation;
}());
}(BaseInvocation));
var MethodInfo = (function () {

@@ -534,3 +587,3 @@ function MethodInfo(obj, name, desc) {

var funcName = Utils.functionName(instance);
result = ProxyES5.methodProxyValue(interceptor, instance, funcName, null);
result = ProxyES5.methodProxyValue(undefined, interceptor, instance, funcName, null);
}

@@ -581,10 +634,10 @@ else {

ProxyES5.prototype.defineMethodProxy = function (that, interceptor, instance, propName, propDesc) {
if (propDesc === void 0) { propDesc = { configurable: false, enumerable: true, writable: false }; }
propDesc.value = ProxyES5.methodProxyValue(interceptor, instance, propName, propDesc);
if (propDesc === void 0) { propDesc = { configurable: true, enumerable: true, writable: false }; }
propDesc.value = ProxyES5.methodProxyValue(that, interceptor, instance, propName, propDesc);
this.defineProperty(that, propName, propDesc);
};
ProxyES5.methodProxyValue = function (interceptor, instance, propName, propDesc) {
ProxyES5.methodProxyValue = function (that, interceptor, instance, propName, propDesc) {
function proxy() {
var method = new MethodInfo(instance, propName, propDesc);
var invocation = new MethodInvocation(method, arguments);
var invocation = new MethodInvocation(that, method, arguments);
interceptor.intercept(invocation);

@@ -596,3 +649,3 @@ return invocation.returnValue;

ProxyES5.prototype.defineValuePropertyProxy = function (that, interceptor, instance, propName, propValue, propDesc) {
if (propDesc === void 0) { propDesc = { configurable: false, enumerable: true }; }
if (propDesc === void 0) { propDesc = { configurable: true, enumerable: true }; }
function getProxy() {

@@ -614,3 +667,3 @@ var method = new PropertyInfo(instance, propName);

ProxyES5.prototype.defineGetSetPropertyProxy = function (that, interceptor, instance, propName, get, set, propDesc) {
if (propDesc === void 0) { propDesc = { configurable: false, enumerable: true }; }
if (propDesc === void 0) { propDesc = { configurable: true, enumerable: true }; }
function getProxy() {

@@ -667,3 +720,3 @@ var method = new PropertyInfo(instance, propName);

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

@@ -679,3 +732,3 @@ return invocation.returnValue;

if (!_.isFunction(propValue) &&
valueInvocation.returnValue &&
!_.isUndefined(valueInvocation.returnValue) &&
valueInvocation.property.desc && valueInvocation.property.desc.value)

@@ -691,3 +744,3 @@ return valueInvocation.returnValue;

var method = new MethodInfo(target, p);
var methodInvocation = new MethodInvocation(method, args);
var methodInvocation = new MethodInvocation(target, method, args);
_this._interceptor.intercept(methodInvocation);

@@ -701,4 +754,8 @@ return methodInvocation.returnValue;

this._interceptor.intercept(invocation);
return true;
return Reflect.set(target, p, value, receiver);
};
ProxyES6Handler.prototype.defineProperty = function (target, p, attributes) {
attributes.configurable = true;
return Reflect.defineProperty(target, p, attributes);
};
return ProxyES6Handler;

@@ -1022,3 +1079,3 @@ }());

var newArgs = this.transformToMatchers(ic.args);
Object.defineProperty(newArgs, "callee", { configurable: false, enumerable: true, writable: false, value: ic.args.callee });
Object.defineProperty(newArgs, "callee", { configurable: true, enumerable: true, writable: false, value: ic.args.callee });
ic.args = newArgs;

@@ -1145,9 +1202,14 @@ this._setupCall = ic;

var __extends$3 = (undefined && undefined.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends$4 = (undefined && undefined.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var MethodCallReturn = (function (_super) {
__extends$3(MethodCallReturn, _super);
__extends$4(MethodCallReturn, _super);
function MethodCallReturn(mock, setupExpression, interceptor, proxy) {

@@ -1195,2 +1257,4 @@ var _this = _super.call(this, mock, setupExpression, interceptor, proxy) || this;

if (desc) {
desc.configurable = true;
desc.enumerable = true;
desc.value = this._returnValueFunc;

@@ -1209,7 +1273,12 @@ Object.defineProperty(obj, name_1, desc);

var __extends = (undefined && undefined.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends = (undefined && undefined.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var StaticMock = (function (_super) {

@@ -1267,9 +1336,14 @@ __extends(StaticMock, _super);

var __extends$4 = (undefined && undefined.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends$5 = (undefined && undefined.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var DynamicMock = (function (_super) {
__extends$4(DynamicMock, _super);
__extends$5(DynamicMock, _super);
function DynamicMock(name, canOverrideTarget, behavior) {

@@ -1276,0 +1350,0 @@ var _this = _super.call(this, {}, canOverrideTarget, behavior) || this;

@@ -111,3 +111,5 @@ 'use strict';

name: 'typemoq-dts-bundle',
main: srcOpts.outDefPath + '/typemoq.d.ts'
main: srcOpts.outDefPath + '/typemoq.d.ts',
emitOnIncludedFileNotFound: true,
emitOnNoIncludedFileNotFound: true
});

@@ -114,0 +116,0 @@ });

{
"name": "typemoq",
"version": "1.2.1",
"version": "1.3.0",
"description": "A simple mocking library for TypeScript",

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

"del": "^0.1.3",
"dts-bundle": "^0.6.1",
"dts-bundle": "^0.7.2",
"gulp": "^3.6.0",

@@ -49,0 +49,0 @@ "gulp-concat": "^2.4.3",

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

* Static and dynamic mocking
* Mock objects, classes (with arguments) and interfaces
* Mock objects, classes (with arguments), constructor functions and interfaces
* Control mock behavior

@@ -121,2 +121,31 @@ * Record and replay expectations

```typescript
interface IBar {
value: string;
anyValue: any;
}
class Bar implements IBar {
value: string = '';
anyValue: any = undefined;
}
class Foo {
constructor(private _bar: IBar) { this._bar = _bar || new Bar(); }
get bar(): IBar { return this._bar; }
do(stringValue: string) { return 'Foo.do:' + stringValue; }
setBar(value: string) { this._bar.value = value; }
}
class GenericFoo<T> {
private _bar: T;
constructor(barCtor?: { new (): T }, public numberValue?: number) {
this._bar = new barCtor();
}
get bar(): T { return this._bar; }
do(stringValue: string) { return 'GenericFoo.do:' + stringValue + ': ' + this._bar.toString(); }
}
// Using class as constructor parameter

@@ -142,2 +171,10 @@ let mock: TypeMoq.IMock<Bar> = TypeMoq.Mock.ofType(Bar);

```typescript
function someFunc() {
return "someFunc was called";
}
function someFuncWithArgs(a: any, b: any, c: any) {
return "someFuncWithArgs was called";
}
// From an existing object

@@ -161,4 +198,2 @@ let bar = new Bar();

* `Function` (as the type of a [function object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function))
* a class type
* an interface type

@@ -168,9 +203,10 @@ ```typescript

let mock: TypeMoq.IMock<Function> = TypeMoq.Mock.ofType<Function>();
```
// Using class as type parameter
* a class type
```typescript
// Using the 'instance' side of the class as type parameter
let mock: TypeMoq.IMock<Bar> = TypeMoq.Mock.ofType<Bar>();
// Using interface as type parameter
let mock: TypeMoq.IMock<IBar> = TypeMoq.Mock.ofType<IBar>();
// Specifying mock behavior

@@ -180,2 +216,17 @@ let mock: TypeMoq.IMock<Foo> = TypeMoq.Mock.ofType<Foo>(undefined, TypeMoq.MockBehavior.Loose);

* a constructor function
```typescript
// Using the 'static' side of the class as type parameter
let mock: TypeMoq.IMock<typeof Bar> = TypeMoq.Mock.ofType<typeof Bar>();
```
* an interface type
```typescript
// Using an interface as type parameter
let mock: TypeMoq.IMock<IBar> = TypeMoq.Mock.ofType<IBar>();
```
As opposed to static mocks, dynamic mocks have some limitations due to the absence of the underlying target instance:

@@ -185,4 +236,43 @@

* No embedded mocks passed as constructor arguments
* Properties return by default a `function` object and not `undefined`
**Note:**
```typescript
interface IThing {
getA(a: string): string;
getB(b: number): number;
getC(): boolean;
valueA: string;
}
let mock: TypeMoq.IMock<IThing> = TypeMoq.Mock.ofType<IThing>();
expect(mock.object.getA("abc")).to.be.undefined;
expect(mock.object.getB(123)).to.be.undefined;
expect(mock.object.getC()).to.be.undefined;
expect(mock.object.valueA).to.be.a("function");
```
* Properties can be set to return any falsy value except `undefined`
```typescript
let mock: TypeMoq.IMock<IBar> = TypeMoq.Mock.ofType<IBar>();
mock.setup(x => x.anyValue).returns(() => null);
expect(mock.object.anyValue).to.be.null;
mock.reset();
mock.setup(x => x.anyValue).returns(() => 0);
expect(mock.object.anyValue).to.eq(0);
mock.reset();
mock.setup(x => x.anyValue).returns(() => undefined);
expect(mock.object.anyValue).to.be.a("function");
```
**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).

@@ -223,2 +313,10 @@

```typescript
class Doer {
doVoid(): void { }
doNumber(n?: number): number { return n || 101; }
doString(s?: string): string { return s || 'xyz'; }
doObject(o?: Object): Object { return o || new Object(); }
doBar(b?: Bar): Bar { return b; }
}
let mock = TypeMoq.Mock.ofType(Doer);

@@ -265,3 +363,3 @@

let bar2 = new Bar();
let mock = Mock.ofType(Doer);
let mock = TypeMoq.Mock.ofType(Doer);

@@ -271,5 +369,36 @@ mock.setup(x => x.doBar(It.is((x: Bar) => x.value === "Ut enim ad minim veniam"))).returns(() => bar2);

To be able to match the static methods of some class, you would need to create a dynamic mock of the type of the class itself. E.g.
```typescript
class Greeter {
private static _instance: Greeter | null;
static instance(): Greeter {
if (!this._instance) {
this._instance = new Greeter();
}
return this._instance;
}
greet(): string {
return 'Hello';
}
}
let greeter = Greeter.instance();
let mock: TypeMoq.IMock<typeof Greeter> = Typemoq.Mock.ofType<typeof Greeter>();
mock.setup(x => x.instance()).returns(() => greeter);
expect(mock.object.instance()).to.eq(greeter);
```
##### Matching properties
```typescript
class FooWithPublicGetterAndSetter {
private _foo: string;
public get foo(): string { return this._foo; }
public set foo(value: string) { this._foo = value; }
}
// Match a property getter

@@ -284,2 +413,17 @@ let mock = TypeMoq.Mock.ofType(FooWithPublicGetterAndSetter);

**Note:**
To be able to match a property make sure the property is initialized.
Otherwise the TypeScript compiler will omit the uninitialized property from the emitted JavaScript and hence TypeMoq will throw a MockException with an 'invalid setup expression' message.
```typescript
class Baz {
value: string = '';
anyValue: any;
}
let mock = TypeMoq.Mock.ofType(Baz);
mock.setup(x => x.value); // OK
mock.setup(x => x.anyValue); // throws MockException - invalid setup expression
```
##### Attaching return callbacks

@@ -430,5 +574,6 @@

**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

@@ -444,2 +589,28 @@ let mockBar = TypeMoq.Mock.ofType(Bar);

* For static mocks, TypeMoq is able to verify any inner calls inside regular functions but not inside lambda ones. E.g.:
```typescript
class FooBar {
register(): void {
this.canExecute();
}
registerLambda = () => {
this.canExecute();
}
canExecute(): void {
console.log("FooBar.canExecute() was called");
}
}
let mock: TypeMoq.IMock<FooBar> = TypeMoq.Mock.ofType(FooBar);
mock.callBase = true;
mock.object.register();
mock.object.registerLambda(); // inside a lambda function calls cannot be verified
mock.verify(x => x.canExecute(), Times.once());
```
##### Verify all expectations at once

@@ -498,2 +669,12 @@

```typescript
// global scope
interface IGlobalBar {
value: string;
}
class GlobalBar implements IGlobalBar {
value: string = '';
}
// Create an instance using class as ctor parameter

@@ -563,2 +744,12 @@ let mock: TypeMoq.IGlobalMock<GlobalBar> = TypeMoq.GlobalMock.ofType(GlobalBar, global);

```typescript
// global scope
function someGlobalFunc() {
return "someGlobalFunc was called";
}
function someGlobalFuncWithArgs(a: any, b: any, c: any) {
return "someGlobalFuncWithArgs was called";
}
// Global no args function is auto sandboxed

@@ -611,2 +802,2 @@ let mock = TypeMoq.GlobalMock.ofInstance(someGlobalFunc);

**Note:**
Within a global 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
Inside the scope of a TypeMoq.GlobalScope, 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 `TypeMoq.GlobalScope.using` function
import * as _ from "lodash";
import { CtorWithArgs } from "./Ctor";
import { PropertyRetriever } from "./PropertyRetriever";

@@ -32,2 +33,8 @@ export class Utils {

}
static clone(target: Object, source: Object) {
let sourceProps = PropertyRetriever.getOwnAndPrototypeEnumerablesAndNonenumerables(source);
for (let p of sourceProps)
Object.defineProperty(target, p.name, p.desc);
}
}

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

Object.defineProperty(newArgs, "callee",
{ configurable: false, enumerable: true, writable: false, value: ic.args.callee });
{ configurable: true, enumerable: true, writable: false, value: ic.args.callee });
ic.args = <IArguments><any>newArgs;

@@ -38,0 +38,0 @@

@@ -74,2 +74,4 @@ import * as all from "./_all";

if (desc) {
desc.configurable = true;
desc.enumerable = true;
desc.value = this._returnValueFunc;

@@ -76,0 +78,0 @@ Object.defineProperty(obj, name, desc);

@@ -7,2 +7,3 @@ export * from "./ICallContext";

export * from "./ProxyES5";
export * from "./ProxyES6";
export * from "./ProxyFactory";

@@ -5,8 +5,19 @@ import * as _ from "lodash";

export class MethodInvocation implements ICallContext {
export abstract class BaseInvocation implements ICallContext {
returnValue: any;
abstract get args(): IArguments;
abstract set args(value: IArguments);
abstract get property(): IPropertyInfo;
abstract invokeBase(): void;
}
export class MethodInvocation extends BaseInvocation {
constructor(
private readonly _that: Object,
private readonly _property: MethodInfo,
private _args?: IArguments) {
super();
}

@@ -17,6 +28,11 @@

get property(): PropertyInfo { return this._property; }
get property(): IPropertyInfo { return this._property; }
invokeBase(): void {
this.returnValue = this._property.toFunc.apply(this._property.obj, this._args);
let thatClone = {};
if (this._that)
common.Utils.clone(thatClone, this._that);
else
thatClone = this._property.obj;
this.returnValue = this._property.toFunc.apply(thatClone, this._args);
}

@@ -30,9 +46,7 @@

export class ValueGetterInvocation implements ICallContext {
returnValue: any;
export class ValueGetterInvocation extends BaseInvocation {
constructor(
private readonly _property: PropertyInfo,
private readonly _property: IPropertyInfo,
readonly value: any) {
super();
this.returnValue = value;

@@ -44,3 +58,3 @@ }

Object.defineProperty(args, "callee",
{ configurable: false, enumerable: true, writable: false, value: null });
{ configurable: true, enumerable: true, writable: false, value: null });
return <any>args;

@@ -50,3 +64,3 @@ }

get property(): PropertyInfo { return this._property; }
get property(): IPropertyInfo { return this._property; }

@@ -63,8 +77,7 @@ invokeBase(): void {

export class ValueSetterInvocation implements ICallContext {
returnValue: any;
export class ValueSetterInvocation extends BaseInvocation {
constructor(
private readonly _property: PropertyInfo,
private readonly _property: IPropertyInfo,
private _args: IArguments) {
super();
}

@@ -75,3 +88,3 @@

get property(): PropertyInfo { return this._property; }
get property(): IPropertyInfo { return this._property; }

@@ -89,8 +102,7 @@ invokeBase(): void {

export class MethodGetterInvocation implements ICallContext {
returnValue: any;
export class MethodGetterInvocation extends BaseInvocation {
constructor(
private readonly _property: PropertyInfo,
private readonly _property: IPropertyInfo,
private readonly _getter: () => any) {
super();
}

@@ -101,3 +113,3 @@

Object.defineProperty(args, "callee",
{ configurable: false, enumerable: true, writable: false, value: null });
{ configurable: true, enumerable: true, writable: false, value: null });
return <any>args;

@@ -107,3 +119,3 @@ }

get property(): PropertyInfo { return this._property; }
get property(): IPropertyInfo { return this._property; }

@@ -120,9 +132,8 @@ invokeBase(): void {

export class MethodSetterInvocation implements ICallContext {
returnValue: any;
export class MethodSetterInvocation extends BaseInvocation {
constructor(
private readonly _property: PropertyInfo,
private readonly _property: IPropertyInfo,
private readonly _setter: (v: any) => void,
private _args: IArguments) {
super();
}

@@ -133,3 +144,3 @@

get property(): PropertyInfo { return this._property; }
get property(): IPropertyInfo { return this._property; }

@@ -176,3 +187,3 @@ invokeBase(): void {

}
toString(): string {

@@ -179,0 +190,0 @@ let objName = common.Utils.objectName(this.obj);

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

let funcName = common.Utils.functionName(instance);
result = ProxyES5.methodProxyValue(interceptor, instance, funcName, null);
result = ProxyES5.methodProxyValue(undefined, interceptor, instance, funcName, null);
}

@@ -121,5 +121,5 @@ else {

propName: string,
propDesc: PropertyDescriptor = { configurable: false, enumerable: true, writable: false }) {
propDesc: PropertyDescriptor = { configurable: true, enumerable: true, writable: false }) {
propDesc.value = ProxyES5.methodProxyValue(interceptor, instance, propName, propDesc);
propDesc.value = ProxyES5.methodProxyValue(that, interceptor, instance, propName, propDesc);

@@ -130,2 +130,3 @@ this.defineProperty(that, propName, propDesc);

private static methodProxyValue<U>(
that: Object,
interceptor: ICallInterceptor,

@@ -138,3 +139,3 @@ instance: U,

let method = new MethodInfo(instance, propName, propDesc);
let invocation: ICallContext = new MethodInvocation(method, arguments);
let invocation: ICallContext = new MethodInvocation(that, method, arguments);
interceptor.intercept(invocation);

@@ -152,3 +153,3 @@ return invocation.returnValue;

propValue: any,
propDesc: PropertyDescriptor = { configurable: false, enumerable: true }) {
propDesc: PropertyDescriptor = { configurable: true, enumerable: true }) {

@@ -180,3 +181,3 @@ function getProxy(): any {

set?: (v: any) => void,
propDesc: PropertyDescriptor = { configurable: false, enumerable: true }) {
propDesc: PropertyDescriptor = { configurable: true, enumerable: true }) {

@@ -183,0 +184,0 @@ function getProxy(): any {

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

let method = new MethodInfo(target, funcName);
let invocation: ICallContext = new MethodInvocation(method, argArray);
let invocation: ICallContext = new MethodInvocation(target, method, argArray);
this._interceptor.intercept(invocation);

@@ -31,4 +31,5 @@

if (!_.isFunction(propValue) &&
valueInvocation.returnValue &&
!_.isUndefined(valueInvocation.returnValue) &&
valueInvocation.property.desc && valueInvocation.property.desc.value) // value getter invocation at execution time
return valueInvocation.returnValue;

@@ -41,3 +42,3 @@ else

let method = new MethodInfo(target, <string>p);
let methodInvocation = new MethodInvocation(method, <any>args);
let methodInvocation = new MethodInvocation(target, method, <any>args);
this._interceptor.intercept(methodInvocation);

@@ -55,5 +56,12 @@

return true;
return Reflect.set(target, p, value, receiver);
}
defineProperty(target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean {
attributes.configurable = true;
return Reflect.defineProperty(target, p, attributes);
}
}

@@ -40,2 +40,14 @@ import { Utils } from "./Utils";

setBar(value: string) { this._bar.value = value; }
register() {
this.canExecute();
}
registerLambda = () => {
this.canExecute();
}
canExecute(): void {
//console.log('Foo.canExecute()');
}
}

@@ -54,2 +66,3 @@

value: string = '';
anyValue: any = undefined;
}

@@ -59,2 +72,3 @@

value: string;
anyValue: any;
}

@@ -188,2 +202,16 @@

export class Greeter {
private static _instance: Greeter | null;
static instance(): Greeter {
if (!this._instance) {
this._instance = new Greeter();
}
return this._instance;
}
greet(): string {
return 'Hello';
}
}
export function doSomething(thing: IThing): string {

@@ -190,0 +218,0 @@ return thing.getA("asdf") + thing.getB(123);

@@ -5,3 +5,3 @@ {

"module": "es2015",
"noImplicitAny": true,
"noImplicitAny": false,
"removeComments": true,

@@ -8,0 +8,0 @@ "preserveConstEnums": true,

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