public void NoUsereReturnsFalse()
        {
            var admin       = new TestableAdmin();
            var contextMock = new Mock <HttpContextBase>();

            contextMock.Setup(c => c.User).Returns((IPrincipal)null);
            Assert.IsFalse(admin.GetAuthorizeCoreResult(contextMock.Object));
        }
        public void UnauthHandlerReturnsForbiddenViewResult()
        {
            var admin   = new TestableAdmin();
            var context = new AuthorizationContext();

            admin.DoHandleUnauthorizedRequest(context);
            Assert.IsInstanceOf <ViewResult>(context.Result);
            Assert.AreEqual("Forbidden", ((ViewResult)context.Result).ViewName);
        }
        public void NonAdminRoleReturnsFalse()
        {
            var admin         = new TestableAdmin();
            var contextMock   = new Mock <HttpContextBase>();
            var principalMock = new Mock <IPrincipal>();

            principalMock.Setup(p => p.IsInRole(PermanentRoles.Admin)).Returns(false);
            contextMock.Setup(c => c.User).Returns(principalMock.Object);
            Assert.IsFalse(admin.GetAuthorizeCoreResult(contextMock.Object));
        }