/// <inheritdoc />
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException(nameof(httpContext));
            }

            var controller          = httpContext.Items[s_controllerKey] as IAuthorizationController;
            var user                = (ClaimsPrincipal)httpContext.User;
            var contextAccessor     = new HttpContextBaseOwinContextAccessor(httpContext);
            var authorizationHelper = new AuthorizationHelper(contextAccessor);

            return(authorizationHelper.IsAuthorizedAsync(controller, user, this).Result);
        }
        public void OwinContextShouldBeCreatedFromHttpContextBase()
        {
            var httpContext = Repository.Create <HttpContextBase>();
            var items       = new Hashtable {
                { "owin.Environment", new Dictionary <string, object>() }
            };

            httpContext.Setup(x => x.Items).Returns(items);

            var owinAccessor = new HttpContextBaseOwinContextAccessor(httpContext.Object);

            Assert.IsNotNull(owinAccessor.Context);
            httpContext.Verify(x => x.Items, Times.Once);
        }