public void HandleNonHttpsRequestExtensibility() { // Arrange Mock<AuthorizationContext> mockAuthContext = new Mock<AuthorizationContext>(); mockAuthContext.Expect(c => c.HttpContext.Request.IsSecureConnection).Returns(false); AuthorizationContext authContext = mockAuthContext.Object; RequireHttpsAttribute attr = new MyRequireHttpsAttribute(); // Act attr.OnAuthorization(authContext); ContentResult result = authContext.Result as ContentResult; // Assert Assert.IsNotNull(result, "Result should have been a ContentResult."); Assert.AreEqual("Custom HandleNonHttpsRequest", result.Content); }
public void HandleNonHttpsRequestExtensibility() { // Arrange Mock <AuthorizationContext> mockAuthContext = new Mock <AuthorizationContext>(); mockAuthContext.Setup(c => c.HttpContext.Request.IsSecureConnection).Returns(false); AuthorizationContext authContext = mockAuthContext.Object; RequireHttpsAttribute attr = new MyRequireHttpsAttribute(); // Act attr.OnAuthorization(authContext); ContentResult result = authContext.Result as ContentResult; // Assert Assert.NotNull(result); Assert.Equal("Custom HandleNonHttpsRequest", result.Content); }