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.1.0 to 1.2.0

src/Proxy/ProxyES5.ts

6

CHANGELOG.md

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

v1.2.0 / 2017-02-07
===================
* support dynamic mocking of Function.prototype
* remove @type/node as a runtime dependency
v1.1.0 / 2017-01-03

@@ -2,0 +8,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={apply:function(t,n,r){var o=i.functionName(t),u=new I(t,o),c=new m(u,r);return e.intercept(c),c.returnValue},get:function(t,n,r){var o=t[n],i=new O(t,n,{value:!0}),u=new b(i,o);return e.intercept(u),u.returnValue&&u.property.desc&&u.property.desc.value?u.returnValue:function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];e.removeInvocation(u);var i=new I(t,n),c=new m(i,r);return e.intercept(c),c.returnValue}},set:function(t,n,r,o){var i=new O(t,n),u=new g(i,[r]);return e.intercept(u),!0}},n=new Proxy({},t);return n}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(){}return e.createProxy=function(e,t){var n=x.of(t,e);return n},e.createProxyES6=function(e){var t=P.of(e);return t},e}(),E=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 j,k=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}(),N=function(){function e(){}return e}(),M=function(){function e(){}return e.prototype.handleIntercept=function(e,t,n){return t.addInvocation(e),l.Continue},e}(),S=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}(),T=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}(),V=function(){function e(){}return e.prototype.handleIntercept=function(e,t,n){return t.mock.callBase?(e.invokeBase(),l.Stop):l.Continue},e}(),L=function(){function e(){}return e.prototype.handleIntercept=function(e,t,n){return l.Continue},e}(),D=function(){function e(e){this._interceptorContext=new k(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 N;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 M,new S,new T,new V,new L];return e},e}(),B=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}(),F=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 B,r=A.createProxy(n,e.targetInstance),i=new o(e,t,n,r);return i},o.ofDynamicMock=function(e,t){var n=new B,r=A.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}(),H=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)},U=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 H(t,e),t.ofStaticMock=function(e,n){var r=new B,o=A.createProxy(r,e.targetInstance),i=new t(e,n,r,o);return i},t.ofDynamicMock=function(e,n){var r=new B,o=A.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}(F),G=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)},q=function(e){function n(t,n,r){var o=e.call(this,t,n,r)||this;return o._interceptor=new D(o),o._proxy=A.createProxy(o._interceptor,t),o}return G(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=U.ofStaticMock(this,e);return this._interceptor.addExpectedCall(t),t},n.prototype.verify=function(e,t){var n=F.ofStaticMock(this,e);this._interceptor.addExpectedCall(n);try{this._interceptor.verifyCallCount(n,t)}catch(r){throw r}},n}(E),R=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)},X=function(e){function t(t,n,r){var o=e.call(this,{},n,r)||this;return t&&(o._name=t),o._interceptor=new D(o),o._proxy=A.createProxyES6(o._interceptor),o}return R(t,e),t.ofType=function(e,n){var r=new t(e,!0,n);return r},t.prototype.setup=function(e){var t=U.ofDynamicMock(this,e);return this._interceptor.addExpectedCall(t),t},t.prototype.verify=function(e,t){var n=F.ofDynamicMock(this,e);this._interceptor.addExpectedCall(n);try{this._interceptor.verifyCallCount(n,t)}catch(r){throw r}},t}(E),Y=function(){function t(){}return t.ofInstance=function(t,n){void 0===n&&(n=e.MockBehavior.Loose);var r=q.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):X.ofType(void 0,r)},t.ofType2=function(t,n,r){void 0===r&&(r=e.MockBehavior.Loose);var o=q.ofType(t,r,n);return o},t}(),W=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"}(j||(j={}));var z=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}(),J=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=q.ofGlobalInstance(n,i),c=t.isFunction(n)?j.Function:j.Value;return new z(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=q.ofInstance(o,r);return new z(i,void 0,j.Class,n)},n.ofType2=function(t,n,r){void 0===n&&(n=window),void 0===r&&(r=e.MockBehavior.Loose);var o=X.ofType(t,r);return new z(o,void 0,j.Class,n)},n}(),K=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 j.Class:c.value=function(){return e.mock.object};break;case j.Function:c.value=e.mock.object;break;case j.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 j.Class:break;case j.Function:break;case j.Value:t.configurable=!0}try{Object.defineProperty(e.container,e.name,t)}catch(r){console.log("3: "+r)}}})}},e}(),Q=function(){function e(){}return e.using=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new K(e);return n},e}();e.Mock=Y,e.It=W,e.Times=n,e.GlobalMock=J,e.GlobalScope=Q,e.MockException=s,Object.defineProperty(e,"__esModule",{value:!0})});
!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})});

@@ -167,3 +167,3 @@ // Generated by dts-bundle v0.6.1

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

@@ -469,8 +469,8 @@ }

declare module 'typemoq/Proxy/Proxy' {
declare module 'typemoq/Proxy/ProxyES5' {
import { IProxy } from "typemoq/Proxy/IProxy";
import { ICallInterceptor } from "typemoq/Proxy/ICallInterceptor";
export class Proxy<T> implements IProxy {
export class ProxyES5<T> implements IProxy {
readonly ___id: string;
static of<U>(instance: U, interceptor: ICallInterceptor): Proxy<U>;
static of<U>(instance: U, interceptor: ICallInterceptor): ProxyES5<U>;
static isProxy(obj: any): boolean;

@@ -477,0 +477,0 @@ }

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash')) :
typeof define === 'function' && define.amd ? define(['exports', 'lodash'], factory) :
(factory((global.TypeMoq = global.TypeMoq || {}),global._));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash')) :
typeof define === 'function' && define.amd ? define(['exports', 'lodash'], factory) :
(factory((global.TypeMoq = global.TypeMoq || {}),global._));
}(this, (function (exports,_) {

@@ -490,4 +490,4 @@

var Proxy$1 = (function () {
function Proxy(interceptor, instance) {
var ProxyES5 = (function () {
function ProxyES5(interceptor, instance) {
var _this = this;

@@ -519,15 +519,15 @@ this.___id = Consts.IPROXY_ID_VALUE;

}
Proxy.of = function (instance, interceptor) {
Proxy.check(instance);
ProxyES5.of = function (instance, interceptor) {
ProxyES5.check(instance);
var result;
if (_.isFunction(instance)) {
var funcName = Utils.functionName(instance);
result = Proxy.methodProxyValue(interceptor, instance, funcName, null);
result = ProxyES5.methodProxyValue(interceptor, instance, funcName, null);
}
else {
result = new Proxy(interceptor, instance);
result = new ProxyES5(interceptor, instance);
}
return result;
};
Proxy.isProxy = function (obj) {
ProxyES5.isProxy = function (obj) {
if (!_.isNil(obj) &&

@@ -539,7 +539,7 @@ !_.isUndefined(obj[Consts.IPROXY_ID_NAME]) && obj[Consts.IPROXY_ID_NAME] === Consts.IPROXY_ID_VALUE)

};
Proxy.check = function (instance) {
Proxy.checkNotNullOrUndefined(instance);
ProxyES5.check = function (instance) {
ProxyES5.checkNotNullOrUndefined(instance);
var ok = false;
if (_.isFunction(instance) ||
(_.isObject(instance) && !Proxy.isPrimitiveObject(instance)))
(_.isObject(instance) && !ProxyES5.isPrimitiveObject(instance)))
ok = true;

@@ -549,7 +549,7 @@ if (!ok)

};
Proxy.prototype.check = function (instance) {
Proxy.checkNotNullOrUndefined(instance);
ProxyES5.prototype.check = function (instance) {
ProxyES5.checkNotNullOrUndefined(instance);
var ok = false;
if (!_.isFunction(instance) &&
(_.isObject(instance) && !Proxy.isPrimitiveObject(instance)))
(_.isObject(instance) && !ProxyES5.isPrimitiveObject(instance)))
ok = true;

@@ -559,7 +559,7 @@ if (!ok)

};
Proxy.checkNotNullOrUndefined = function (instance) {
ProxyES5.checkNotNullOrUndefined = function (instance) {
if (_.isNil(instance))
throw new MockException(MockExceptionReason.InvalidProxyArg, instance, "'" + instance + "'; argument is required");
};
Proxy.isPrimitiveObject = function (obj) {
ProxyES5.isPrimitiveObject = function (obj) {
var result = false;

@@ -573,8 +573,8 @@ if (_.isFunction(obj) ||

};
Proxy.prototype.defineMethodProxy = function (that, interceptor, instance, propName, propDesc) {
ProxyES5.prototype.defineMethodProxy = function (that, interceptor, instance, propName, propDesc) {
if (propDesc === void 0) { propDesc = { configurable: false, enumerable: true, writable: false }; }
propDesc.value = Proxy.methodProxyValue(interceptor, instance, propName, propDesc);
propDesc.value = ProxyES5.methodProxyValue(interceptor, instance, propName, propDesc);
this.defineProperty(that, propName, propDesc);
};
Proxy.methodProxyValue = function (interceptor, instance, propName, propDesc) {
ProxyES5.methodProxyValue = function (interceptor, instance, propName, propDesc) {
function proxy() {

@@ -588,3 +588,3 @@ var method = new MethodInfo(instance, propName, propDesc);

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

@@ -606,3 +606,3 @@ function getProxy() {

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

@@ -624,3 +624,3 @@ function getProxy() {

};
Proxy.prototype.defineProperty = function (obj, name, desc) {
ProxyES5.prototype.defineProperty = function (obj, name, desc) {
try {

@@ -633,50 +633,14 @@ Object.defineProperty(obj, name, desc);

};
return Proxy;
return ProxyES5;
}());
var ProxyES6 = (function () {
function ProxyES6(interceptor) {
function ProxyES6(handler) {
this.___id = Consts.IPROXY_ID_VALUE;
var handler = {
apply: function (target, thisArg, argArray) {
var funcName = Utils.functionName(target);
var method = new MethodInfo(target, funcName);
var invocation = new MethodInvocation(method, argArray);
interceptor.intercept(invocation);
return invocation.returnValue;
},
get: function (target, p, receiver) {
var propValue = target[p];
var method = new PropertyInfo(target, p, { value: true });
var valueInvocation = new ValueGetterInvocation(method, propValue);
interceptor.intercept(valueInvocation);
if (valueInvocation.returnValue &&
valueInvocation.property.desc && valueInvocation.property.desc.value)
return valueInvocation.returnValue;
else
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
interceptor.removeInvocation(valueInvocation);
var method = new MethodInfo(target, p);
var methodInvocation = new MethodInvocation(method, args);
interceptor.intercept(methodInvocation);
return methodInvocation.returnValue;
};
},
set: function (target, p, value, receiver) {
var method = new PropertyInfo(target, p);
var invocation = new ValueSetterInvocation(method, [value]);
interceptor.intercept(invocation);
return true;
}
};
var p = new Proxy({}, handler);
var p = new Proxy((function () { }), handler);
return p;
}
ProxyES6.of = function (interceptor) {
ProxyES6.of = function (handler) {
ProxyES6.check();
var result = new ProxyES6(interceptor);
var result = new ProxyES6(handler);
return result;

@@ -691,2 +655,45 @@ };

var ProxyES6Handler = (function () {
function ProxyES6Handler(_interceptor) {
this._interceptor = _interceptor;
}
ProxyES6Handler.prototype.apply = function (target, thisArg, argArray) {
var funcName = Utils.functionName(target);
var method = new MethodInfo(target, funcName);
var invocation = new MethodInvocation(method, argArray);
this._interceptor.intercept(invocation);
return invocation.returnValue;
};
ProxyES6Handler.prototype.get = function (target, p, receiver) {
var _this = this;
var propValue = target[p];
var method = new PropertyInfo(target, p, { value: true });
var valueInvocation = new ValueGetterInvocation(method, propValue);
this._interceptor.intercept(valueInvocation);
if (!_.isFunction(propValue) &&
valueInvocation.returnValue &&
valueInvocation.property.desc && valueInvocation.property.desc.value)
return valueInvocation.returnValue;
else
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
_this._interceptor.removeInvocation(valueInvocation);
var method = new MethodInfo(target, p);
var methodInvocation = new MethodInvocation(method, args);
_this._interceptor.intercept(methodInvocation);
return methodInvocation.returnValue;
};
};
ProxyES6Handler.prototype.set = function (target, p, value, receiver) {
var method = new PropertyInfo(target, p);
var invocation = new ValueSetterInvocation(method, [value]);
this._interceptor.intercept(invocation);
return true;
};
return ProxyES6Handler;
}());
var ProxyFactory = (function () {

@@ -696,7 +703,8 @@ function ProxyFactory() {

ProxyFactory.createProxy = function (interceptor, instance) {
var proxy = Proxy$1.of(instance, interceptor);
var proxy = ProxyES5.of(instance, interceptor);
return proxy;
};
ProxyFactory.createProxyES6 = function (interceptor) {
var proxy = ProxyES6.of(interceptor);
var proxyHandler = new ProxyES6Handler(interceptor);
var proxy = ProxyES6.of(proxyHandler);
return proxy;

@@ -1223,3 +1231,3 @@ };

var value;
if (Proxy$1.isProxy(x))
if (ProxyES5.isProxy(x))
return x;

@@ -1226,0 +1234,0 @@ };

{
"name": "typemoq",
"version": "1.1.0",
"version": "1.2.0",
"description": "A simple mocking library for TypeScript",

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

"@types/lodash": "^4.14.37",
"@types/node": "^6.0.45",
"lodash": "^4.16.4",

@@ -45,2 +44,3 @@ "postinstall-build": "^2.1.3"

"@types/mocha": "^2.2.32",
"@types/node": "^6.0.45",
"chai": "^3.5.0",

@@ -47,0 +47,0 @@ "del": "^0.1.3",

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

export * from "./IProxy";
export * from "./Proxy";
export * from "./ProxyES5";
export * from "./ProxyFactory";
///<reference path="../../node_modules/typescript/lib/lib.es6.d.ts"/>
import * as common from "../Common/_all";
import * as error from "../Error/_all";
import { Consts } from "../Consts";
import { IProxy } from "./IProxy";
import { ICallContext } from "./ICallContext";
import { ICallInterceptor } from "./ICallInterceptor";
import { PropertyInfo, MethodInfo, MethodInvocation, MethodGetterInvocation, MethodSetterInvocation, ValueGetterInvocation, ValueSetterInvocation } from "./Invocation";

@@ -14,57 +10,13 @@ export class ProxyES6<T> implements IProxy {

private constructor(interceptor: ICallInterceptor) {
let handler: ProxyHandler<T> = {
apply: (target: T, thisArg: any, argArray?: any): any => {
let funcName = common.Utils.functionName(target);
let method = new MethodInfo(target, funcName);
let invocation: ICallContext = new MethodInvocation(method, argArray);
interceptor.intercept(invocation);
return invocation.returnValue;
},
get: (target: T, p: PropertyKey, receiver: any): any => {
let propValue = (<any>target)[p];
let method = new PropertyInfo(target, <string>p, { value: true });
let valueInvocation = new ValueGetterInvocation(method, propValue);
interceptor.intercept(valueInvocation);
if (valueInvocation.returnValue &&
valueInvocation.property.desc && valueInvocation.property.desc.value) // value getter invocation at execution time
return valueInvocation.returnValue;
else
return function (...args: any[]) {
interceptor.removeInvocation(valueInvocation);
let method = new MethodInfo(target, <string>p);
let methodInvocation = new MethodInvocation(method, <any>args);
interceptor.intercept(methodInvocation);
return methodInvocation.returnValue;
}
},
set: (target: T, p: PropertyKey, value: any, receiver: any): boolean => {
let method = new PropertyInfo(target, <string>p);
let invocation: ICallContext = new ValueSetterInvocation(method, <any>[value]);
interceptor.intercept(invocation);
return true;
}
};
let p = <ProxyES6<T>>new Proxy({}, handler);
private constructor(handler: ProxyHandler<T>) {
let p = <ProxyES6<T>>new Proxy(<any>(() => {}), handler);
return p;
}
static of<U>(interceptor: ICallInterceptor): ProxyES6<U> {
static of<U>(handler: ProxyHandler<U>): ProxyES6<U> {
ProxyES6.check();
let result = new ProxyES6(interceptor);
let result = new ProxyES6(handler);
return result;
}
private static check(): void {

@@ -75,2 +27,2 @@ if (typeof Proxy === "undefined")

}
}
}
import { ICallInterceptor } from "./ICallInterceptor";
import { Proxy } from "./Proxy";
import { ProxyES5 } from "./ProxyES5";
import { ProxyES6 } from "./ProxyES6";
import { ProxyES6Handler } from "./ProxyES6Handler";

@@ -8,3 +9,3 @@ export class ProxyFactory {

static createProxy<T>(interceptor: ICallInterceptor, instance: T): T {
let proxy: T = <T><any>Proxy.of(instance, interceptor);
let proxy: T = <T><any>ProxyES5.of(instance, interceptor);
return proxy;

@@ -14,6 +15,6 @@ }

static createProxyES6<T>(interceptor: ICallInterceptor): T {
let proxy: T = <T><any>ProxyES6.of(interceptor);
let proxyHandler: ProxyES6Handler<T> = new ProxyES6Handler(interceptor);
let proxy: T = <T><any>ProxyES6.of(proxyHandler);
return proxy;
}
}

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

var value: any;
if (all.Proxy.isProxy(x))
if (all.ProxyES5.isProxy(x))
return x;

@@ -47,0 +47,0 @@ };

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