public void ShouldAuthoriseIfNotAuthenticated() { // arrange AuthoriseAttribute attr = new AuthoriseAttribute { RedirectTo = "/here", DoAuthorise = true }; // act attr.OnAuthorization(m_context); // assert Assert.IsTrue(m_context.Result is HttpUnauthorizedResult); }
public void ShouldRedirectIfNotAuthenticated() { // arrange AuthoriseAttribute attr = new AuthoriseAttribute { RedirectTo = "/here" }; // act attr.OnAuthorization(m_context); // assert Assert.IsTrue(m_context.Result is RedirectResult); RedirectResult redirect = m_context.Result as RedirectResult; Assert.AreEqual("/here", redirect.Url); }
public void ShouldDoNothingIfAuthenticated() { // arrange m_httpContext.WithUser(MockHelpers.User().WithIdentity(MockHelpers.Identity().WithAuthenticationStatus(true))); AuthoriseAttribute attr = new AuthoriseAttribute(); // act attr.OnAuthorization(m_context); // assert Assert.AreEqual(null, m_context.Result); }