Ejemplo n.º 1
0
 public void NoProxy()
 {
     for (int i = 0; i < OperationsPerInvoke; i++)
     {
         FInstance.DoSomething(Param);
     }
 }
Ejemplo n.º 2
0
 public void Duck()
 {
     for (int i = 0; i < OperationsPerInvoke; i++)
     {
         FDuck.DoSomething(Param);
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public int NoProxy() => FInstance.DoSomething(Param);
Ejemplo n.º 7
0
 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();
        }