public async Task HandleAsyncShouldPassThrough()
        {
            var mockRequirementHandler = Repository.Create <IAuthorizationHandler>();
            var innerWasHandled        = false;

            mockRequirementHandler.Setup(x => x.HandleAsync(It.IsAny <AuthorizationContext>())).Returns(() =>
            {
                innerWasHandled = true;
                return(Task.FromResult(0));
            });

            var context = new AuthorizationContext(new [] { mockRequirementHandler.As <IAuthorizationRequirement>().Object }, null, null);
            var handler = new PassThroughAuthorizationHandler();
            await handler.HandleAsync(context);

            Assert.IsTrue(innerWasHandled, "The inner handler was not called");
        }
 public async Task HandleAsyncShouldThrowWhenContextIsNull()
 {
     var handler = new PassThroughAuthorizationHandler();
     await handler.HandleAsync(null);
 }
        public void InfinitePassThroughShouldNotOccur()
        {
            var handler = new PassThroughAuthorizationHandler();

            Assert.IsNotInstanceOfType(handler, typeof(IAuthorizationRequirement));
        }