public void Intercept_WhenInterceptorIsNull_ThenThrowInterceptorNullException()
        {
            var dispatcherProxyInterceptorAdapter = new DispatcherProxyInterceptorAdapter();
            var invocation = new DispatchProxyInvocation(null, null, null);

            Assert.Throws <InterceptorNullException>(() => dispatcherProxyInterceptorAdapter.Intercept(invocation));
        }
        public void Intercept()
        {
            var expectedReturnedValue             = "Returned value";
            var dispatcherProxyInterceptorAdapter = new DispatcherProxyInterceptorAdapter();
            var interceptorMock = new Mock <IInterceptronInterceptor>();

            interceptorMock.Setup(i => i.Intercept(It.IsAny <object>())).Returns(expectedReturnedValue);
            dispatcherProxyInterceptorAdapter.Interceptor = interceptorMock.Object;
            var invocation = new DispatchProxyInvocation(null, null, null);

            var actualReturnedValue = dispatcherProxyInterceptorAdapter.Intercept(invocation);

            Assert.AreEqual(expectedReturnedValue, actualReturnedValue);
            interceptorMock.Verify(i => i.Intercept(invocation), Times.Once);
        }
        public void Intercept_WhenInvocationIsNotDispatchProxyInvocation_ThenThrowInvalidCastExceptiona()
        {
            var expectedReturnedValue = "Returned value";
            var interceptorMock       = new Mock <DispatchProxyInterceptor>();

            interceptorMock.Setup(i => i.Intercept(It.IsAny <DispatchProxyInvocation>()))
            .Returns(expectedReturnedValue);
            var invocation = new DispatchProxyInvocation(null, null, null);
            var interceptronInterceptorAdapter = new InterceptronInterceptorAdapter(interceptorMock.Object);

            var actualReturnedValue = interceptronInterceptorAdapter.Intercept(invocation);

            Assert.AreEqual(expectedReturnedValue, actualReturnedValue);
            Assert.AreEqual(interceptorMock.Object, interceptronInterceptorAdapter.Interceptor);
            interceptorMock.Verify(i => i.Intercept(invocation), Times.Once);
        }