示例#1
0
        public void CallInvocationProceedMethod_WhenUserIsLogged()
        {
            // arrange
            var userProvider = new Mock <IUserProvider>();

            userProvider.Setup(x => x.IsLogged).Returns(true);

            var interceptor = new UserAuthenticatorInterceptor(userProvider.Object);

            var invocationMock = new Mock <IInvocation>();

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

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

            // assert
            invocationMock.Verify(x => x.Proceed(), Times.Once);
        }
示例#2
0
        public void SetTheReturnValueOfTheInvocation_WhenUserIsNotLogged()
        {
            // arrange
            var userProvider = new Mock <IUserProvider>();

            userProvider.Setup(x => x.IsLogged).Returns(false);

            var interceptor = new UserAuthenticatorInterceptor(userProvider.Object);

            var invocationMock = new Mock <IInvocation>();

            invocationMock.Setup(x => x.Proceed());
            invocationMock.Setup(x => x.Request.Target).Returns(new object());
            invocationMock.SetupSet(x => x.ReturnValue = It.IsAny <string>());

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

            // assert
            invocationMock.VerifySet(x => x.ReturnValue = It.IsAny <string>(), Times.Once);
        }