예제 #1
0
        public void NotThrow_WhenInvocationProceedMethodDoesNotThrow()
        {
            // arrange
            var invocationMock = new Mock <IInvocation>();

            invocationMock.Setup(x => x.Proceed());

            var interceptor = new CommandProcessorInterceptor();

            // act & assert
            Assert.DoesNotThrow(() => interceptor.Intercept(invocationMock.Object));
        }
예제 #2
0
        public void ThrowInvalidCommandException_WhenGenericExceptionIsThrown()
        {
            // arrange
            string exceptionMessage = "message";

            var invocationMock = new Mock <IInvocation>();

            invocationMock.Setup(x => x.Proceed()).Throws(new Exception(exceptionMessage));

            var interceptor = new CommandProcessorInterceptor();

            // act & assert
            Assert.Throws <InvalidCommandException>(() => interceptor.Intercept(invocationMock.Object));
        }
예제 #3
0
        public void RethrowUserAuthenticationException_WhenUserAuthenticationExceptionIsThrown()
        {
            // arrange
            string exceptionMessage = "message";

            var invocationMock = new Mock <IInvocation>();

            invocationMock.Setup(x => x.Proceed()).Throws(new UserAuthenticationException(exceptionMessage));

            var interceptor = new CommandProcessorInterceptor();

            // act & assert
            Assert.Throws <UserAuthenticationException>(() => interceptor.Intercept(invocationMock.Object));
        }
예제 #4
0
        public void CallInvocationProceedMethod()
        {
            // arrange
            var invocationMock = new Mock <IInvocation>();

            invocationMock.Setup(x => x.Proceed());

            var interceptor = new CommandProcessorInterceptor();

            // act
            interceptor.Intercept(invocationMock.Object);

            // assert
            invocationMock.Verify(x => x.Proceed(), Times.Once);
        }