public void OnEndRequest_IfDisableRedirectAndStatusIsNotRedirect_DoNothing()
        {
            // Arrange
            HttpResponse response = new HttpResponse(null);
            IDictionary contextItems = new Hashtable();
            Mock<HttpContextBase> contextMock = new Mock<HttpContextBase>() { DefaultValue = DefaultValue.Mock };
            DisableRedirectStub disableRedirectStub = new DisableRedirectStub(contextItems, response);

            contextMock.SetupGet(hcb => hcb.Items).Returns(contextItems);
            response.StatusCode = 200;

            // Act
            SuppressFormsAuthRedirectModule.DisableAuthenticationRedirect(contextMock.Object);
            SuppressFormsAuthRedirectModule.EnsureRestoreUnauthorized(disableRedirectStub);

            // Assert
            Assert.Equal(200, response.StatusCode);
        }
        public void OnEndRequest_IfEnableRedirectAndStatusIsRedirect_DoNothing()
        {
            // Arrange
            HttpResponse           response     = new HttpResponse(null);
            IDictionary            contextItems = new Hashtable();
            Mock <HttpContextBase> contextMock  = new Mock <HttpContextBase>()
            {
                DefaultValue = DefaultValue.Mock
            };
            DisableRedirectStub disableRedirectStub = new DisableRedirectStub(contextItems, response);

            contextMock.SetupGet(hcb => hcb.Items).Returns(contextItems);
            response.StatusCode = 302;

            // Act
            SuppressFormsAuthRedirectModule.AllowAuthenticationRedirect(contextMock.Object);
            SuppressFormsAuthRedirectModule.EnsureRestoreUnauthorized(disableRedirectStub);

            // Assert
            Assert.Equal(302, response.StatusCode);
        }
        public void OnEndRequest_IfWebApiControllerReturnsARedirect_DoNothing() {
            // Arrange
            HttpResponse response = new HttpResponse(null);
            IDictionary contextItems = new Hashtable();
            Mock<HttpContextBase> contextMock = new Mock<HttpContextBase>() { DefaultValue = DefaultValue.Mock };
            DisableRedirectStub disableRedirectStub = new DisableRedirectStub(contextItems, response);

            contextMock.SetupGet(hcb => hcb.Items).Returns(contextItems);
            response.StatusCode = 302;

            // Act
            HttpControllerHandler.EnsureSuppressFormsAuthenticationRedirect(contextMock.Object);

            SuppressFormsAuthRedirectModule.AllowAuthenticationRedirect(contextMock.Object);
            SuppressFormsAuthRedirectModule.EnsureRestoreUnauthorized(disableRedirectStub);

            // Assert
            AssertEx.Equal(302, response.StatusCode);
        }