public void GivenAFilter_WhenTheUserIsNull_ThenTheFilterReturnsFalse() { AuthorizationContext filterContext = CreateFilterContext(); _mockHttpContext.Setup(h => h.User).Returns((IPrincipal) null); var loggedInUserAttribute = new AuthorizeLoggedInUserAttribute(); loggedInUserAttribute.OnAuthorization(filterContext); Assert.That(filterContext.Result, Is.TypeOf<RedirectResult>()); }
public void GivenAFilter_WhenTheUserIsNotLoggedIn_ThenTheFilterReturnsFalse() { AuthorizationContext filterContext = CreateFilterContext(); var model = new UserViewModel {IsLoggedIn = false}; _mockHttpContext.Setup(h => h.User).Returns(model); var loggedInUserAttribute = new AuthorizeLoggedInUserAttribute(); loggedInUserAttribute.OnAuthorization(filterContext); Assert.That(filterContext.Result, Is.TypeOf<RedirectResult>()); }