コード例 #1
0
 public void NoProxy()
 {
     for (int i = 0; i < OperationsPerInvoke; i++)
     {
         FInstance.DoSomething(Param);
     }
 }
コード例 #2
0
 public void Duck()
 {
     for (int i = 0; i < OperationsPerInvoke; i++)
     {
         FDuck.DoSomething(Param);
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #6
0
ファイル: GeneratedProxy.cs プロジェクト: Sholtee/proxygen
 public int NoProxy() => FInstance.DoSomething(Param);
コード例 #7
0
ファイル: GeneratedDuck.cs プロジェクト: Sholtee/proxygen
 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();
        }