Example #1
0
        public void InvokeIShouldCacheInvocationReturnValueStrategyShouldCacheReturnValueMethodOnceWithCorrectParameter()
        {
            // Arrange
            var shouldCacheInvocationReturnValueStrategy = new Mock <IShouldCacheInvocationReturnValueStrategy>();
            var decoratedCachingInterceptor = new Mock <ICachingInterceptor>();

            var managedCachingInterceptor = new ManagedCachingInterceptor(shouldCacheInvocationReturnValueStrategy.Object, decoratedCachingInterceptor.Object);

            var invocation = new Mock <IInvocation>();

            // Act
            managedCachingInterceptor.Intercept(invocation.Object);

            // Assert
            shouldCacheInvocationReturnValueStrategy.Verify(s => s.ShouldCacheReturnValue(invocation.Object), Times.Once);
        }
Example #2
0
        public void InvokeIInvocationProceedMethodWithCorrectParameter_WhenIShouldCacheInvocationReturnValueStrategyReturnsFalse()
        {
            // Arrange
            var shouldCacheInvocationReturnValueStrategy = new Mock <IShouldCacheInvocationReturnValueStrategy>();
            var decoratedCachingInterceptor = new Mock <ICachingInterceptor>();

            var managedCachingInterceptor = new ManagedCachingInterceptor(shouldCacheInvocationReturnValueStrategy.Object, decoratedCachingInterceptor.Object);

            shouldCacheInvocationReturnValueStrategy.Setup(s => s.ShouldCacheReturnValue(It.IsAny <IInvocation>())).Returns(false);

            var invocation = new Mock <IInvocation>();

            // Act
            managedCachingInterceptor.Intercept(invocation.Object);

            // Assert
            invocation.Verify(i => i.Proceed(), Times.Once);
        }