Blog.Common.Web.Tests.Attributes.BlogApiAuthorizationAttributeTest.ShouldReturnUnauthorizedWhenNotAuthenticated C# (CSharp) Method

ShouldReturnUnauthorizedWhenNotAuthenticated() private method

private ShouldReturnUnauthorizedWhenNotAuthenticated ( ) : void
return void
        public void ShouldReturnUnauthorizedWhenNotAuthenticated()
        {
            _principal.SetupGet(x => x.Identity.IsAuthenticated).Returns(false);
            _principal.SetupGet(x => x.Identity.Name).Returns("foo");
            var httpAuthenticationContext = new HttpAuthenticationContext(_httpActionContext, _principal.Object);

            var attribute = new BlogApiAuthorizationAttribute();
            attribute.OnAuthentication(httpAuthenticationContext);

            Assert.IsNotNull(httpAuthenticationContext.ErrorResult);
        }