예제 #1
0
        public void RequiresAuthentication_NullUser_ReturnsUnauthenticated()
        {
            var attr           = new RequiresAuthenticationAttribute();
            var httpCtx        = new Fakes.FakeHttpContext();
            var shouldContinue = attr.ShouldContinue(httpCtx);

            Assert.False(shouldContinue.ShouldContinue);
            Assert.Equal(ApiFilterRunResult.Unauthenticated.SetResponseCode, shouldContinue.SetResponseCode);
        }
예제 #2
0
        public void RequiresAuthentication_AuthenticatedUser_ReturnsContinue()
        {
            var attr    = new RequiresAuthenticationAttribute();
            var httpCtx = new Fakes.FakeHttpContext();

            httpCtx.User = UserSetup.GetUser();
            var shouldContinue = attr.ShouldContinue(httpCtx);

            Assert.True(shouldContinue.ShouldContinue);
        }