コード例 #1
0
        public void ShouldNotInterceptConstructorsWhenIntereptingAllMethodCalls()
        {
            var modifiedTargetType = GetModifiedTargetType((name, type) => type.InterceptAllMethodCalls());
            var instance           = Activator.CreateInstance(modifiedTargetType);
            var aroundInvoke       = new SampleAroundInvoke();
            var provider           = new SampleAroundInvokeProvider(aroundInvoke);

            AroundInvokeMethodCallRegistry.AddProvider(provider);
            var targetMethod = modifiedTargetType.GetMethod("DoSomething");

            targetMethod.Invoke(instance, null);

            Assert.IsTrue(aroundInvoke.BeforeInvokeWasCalled);
            Assert.IsTrue(aroundInvoke.AfterInvokeWasCalled);
        }
コード例 #2
0
        public void ShouldCallStaticAroundInvokeProvider()
        {
            var modifiedTargetType = GetModifiedTargetType();
            var instance           = Activator.CreateInstance(modifiedTargetType);
            var aroundInvoke       = new SampleAroundInvoke();
            var provider           = new SampleAroundInvokeProvider(aroundInvoke);

            AroundInvokeMethodCallRegistry.AddProvider(provider);

            var targetMethod = modifiedTargetType.GetMethod("DoSomething");

            targetMethod.Invoke(instance, null);

            Assert.IsTrue(aroundInvoke.BeforeInvokeWasCalled);
            Assert.IsTrue(aroundInvoke.AfterInvokeWasCalled);
        }
コード例 #3
0
 public override void Term()
 {
     AroundInvokeMethodCallRegistry.Clear();
 }
コード例 #4
0
 protected override void Term()
 {
     AroundInvokeMethodCallRegistry.Clear();
 }