public virtual void before_each() { autoSubstitute = new AutoSubstitute(); targetDomain = autoSubstitute.Resolve <ITargetAppDomain>(); appDomainFactory = autoSubstitute.Resolve <IAppDomainFactory>(); appDomainFactory.Create(somePath).Returns(targetDomain); proxyable = autoSubstitute.Resolve <IDummyProxyable>(); proxyableFactory = autoSubstitute.Resolve <IProxyableFactory <IDummyProxyable> >(); proxyableFactory.CreateProxy(targetDomain).Returns(proxyable); runner = new CrossDomainRunner <IDummyProxyable, float>(appDomainFactory, proxyableFactory); proxyable.PassInput(Arg.Any <float>()).Returns(callInfo => { float input = callInfo.Arg <float>(); return(input); }); }
// initial implementation taken from // http://thevalerios.net/matt/2008/06/run-anonymous-methods-in-another-appdomain/ public CrossDomainRunner(IAppDomainFactory appDomainFactory, IProxyableFactory <TProxyable> proxyableFactory) { this.appDomainFactory = appDomainFactory; this.proxyableFactory = proxyableFactory; }