예제 #1
0
        public async Task ShouldNotCallTargetForTaskMethod()
        {
            Mock <IInterceptor> targetInterceptor = new Mock <IInterceptor>();
            var sampleInterceptor = new SampleAsyncInterceptor(targetInterceptor.Object);
            var targetMock        = new Mock <IMethodWithTaskReturnValue>();
            var proxy             = CreateProxy(targetMock.Object, sampleInterceptor);
            await proxy.Execute();

            targetInterceptor.Verify(m => m.Invoke(It.IsAny <IInvocationInfo>()), Times.Never);
        }
예제 #2
0
        public async Task ShouldInterceptAsyncTaskOfTMethod()
        {
            Mock <IInterceptor> targetInterceptor = new Mock <IInterceptor>();
            var sampleInterceptor = new SampleAsyncInterceptor(targetInterceptor.Object);
            var targetMock        = new Mock <IMethodWithTaskOfTReturnValue>();
            var proxy             = CreateProxy(targetMock.Object, sampleInterceptor);
            await proxy.Execute();

            Assert.True(sampleInterceptor.InterceptedTaskOfTMethod);
        }