public void Must_use_interceptor()
        {
          this.Container.RegisterType<InterceptedTarget, InterceptedTarget>(new Intercept<ForwardToMockInterceptor>());

            var interceptor = new ForwardToMockInterceptor();
            this.Container.RegisterInstance(typeof(ForwardToMockInterceptor), interceptor);

            interceptor.Mock
                .Setup(x => x.Intercept(It.IsAny<IInvocation>()))
                .Callback<IInvocation>(invocation => invocation.Proceed());

            this.Container.Resolve<InterceptedTarget>().Foo();

            interceptor.Mock.Verify(x => x.Intercept(It.Is<IInvocation>(invocation => invocation.Method.Name == "Foo")));
        } 
Exemplo n.º 2
0
        public void Must_use_interceptor()
        {
            this.Container.RegisterType <InterceptedTarget, InterceptedTarget>(new Intercept <ForwardToMockInterceptor>());

            var interceptor = new ForwardToMockInterceptor();

            this.Container.RegisterInstance(typeof(ForwardToMockInterceptor), interceptor);

            interceptor.Mock
            .Setup(x => x.Intercept(It.IsAny <IInvocation>()))
            .Callback <IInvocation>(invocation => invocation.Proceed());

            this.Container.Resolve <InterceptedTarget>().Foo();

            interceptor.Mock.Verify(x => x.Intercept(It.Is <IInvocation>(invocation => invocation.Method.Name == "Foo")));
        }