public void HandleRequirementTestIsAdmin()
        {
            var item = new DownloadItem {
                Owner = TestHelper.ItemOwner
            };
            var requirement = new ItemOwnershipRequirement();

            var context = new AuthorizationHandlerContext(
                new[] { requirement },
                TestHelper.Admin.MapToClaimPrincipal(),
                item
                );

            var handler = new ItemOwnershipAuthorizationHandler();

            handler.HandleAsync(context).Wait();
            Assert.IsFalse(context.HasSucceeded);
        }
        public void HandleRequirementTestDifferentOwner()
        {
            var item = new DownloadItem {
                Owner = TestHelper.ItemOwner
            };
            var requirement = new ItemOwnershipRequirement();

            var context = new AuthorizationHandlerContext(
                new[] { requirement },
                TestHelper.NotAnItemOwner.MapToClaimPrincipal(),
                item
                );

            var handler = new ItemOwnershipAuthorizationHandler();

            handler.HandleAsync(context).Wait();
            Assert.False(context.HasSucceeded);
            Assert.AreEqual(403, ((DownloadItemBaseRequirement)context.Requirements.First()).HttpCode);
            Assert.AreEqual(DownloadItemAuthorizationError.UserNotAllowed, ((DownloadItemBaseRequirement)context.Requirements.First()).Error);
        }