public void NoProxy() { for (int i = 0; i < OperationsPerInvoke; i++) { FInstance.DoSomething(Param); } }
public void Duck() { for (int i = 0; i < OperationsPerInvoke; i++) { FDuck.DoSomething(Param); } }
public void CanInterceptTargetWithInstanceInterceptorUsingGenericVersion() { bool invoked = false; IInterceptionBehavior interceptionBehavior = new DelegateInterceptionBehavior((mi, next) => { invoked = true; return(mi.CreateMethodReturn(100)); }); IInterface proxy = Intercept.ThroughProxyWithAdditionalInterfaces <IInterface>( new BaseClass(10), new InterfaceInterceptor(), new[] { interceptionBehavior }, Type.EmptyTypes); int value = proxy.DoSomething(); Assert.AreEqual(100, value); Assert.IsTrue(invoked); }
public void CanSetUpInterceptorThroughInjectionMemberForExistingInterceptor() { CallCountInterceptionBehavior interceptionBehavior = new CallCountInterceptionBehavior(); IUnityContainer container = new UnityContainer(); container.AddNewExtension <Interception>(); container.RegisterType <IInterface, BaseClass>( "test", new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior(interceptionBehavior)); IInterface instance = container.Resolve <IInterface>("test"); instance.DoSomething("1"); Assert.AreEqual(1, interceptionBehavior.CallCount); }
public void CanSetUpInterceptorThroughInjectionMember() { CallCountHandler handler = new CallCountHandler(); IUnityContainer container = new UnityContainer(); container.AddNewExtension <Interception>(); container.Configure <Interception>() .AddPolicy("policy") .AddMatchingRule <AlwaysMatchingRule>() .AddCallHandler(handler); container.RegisterType <IInterface, BaseClass>( "test", new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <PolicyInjectionBehavior>()); IInterface instance = container.Resolve <IInterface>("test"); instance.DoSomething("1"); Assert.AreEqual(1, handler.CallCount); }
public int NoProxy() => FInstance.DoSomething(Param);
public void Duck() => FDuck.DoSomething(Param);
public void IsEquivalentTo_Matches_Same_Complex_Types() { var complexType = _fixture.Create <ComplexType>(); _fake.DoSomething(complexType); A.CallTo(() => _fake.DoSomething(A <ComplexType> .That.IsEquivalentTo(complexType))).MustHaveHappenedOnceExactly(); }