public async Task Handle_AuthorisersEmpty_CallsNext()
        {
            var behaviour = new AuthorizationBehaviour <CreateBoardCommand, BoardCreatedDto>(new List <IAuthorizer <CreateBoardCommand> >());

            await behaviour.Handle(new CreateBoardCommand(), new CancellationToken(), _next.Object);

            _next.Verify(next => next(), Times.Once);
        }
        public async Task Handler_AuthoriserReturnsTrue_CallsNext()
        {
            _authoriser.Setup(a => a.Authorise(It.IsAny <CreateBoardCommand>(), It.IsAny <CancellationToken>())).ReturnsAsync(true);
            var authorisers = new List <IAuthorizer <CreateBoardCommand> > {
                _authoriser.Object
            };
            var behaviour = new AuthorizationBehaviour <CreateBoardCommand, BoardCreatedDto>(authorisers);

            await behaviour.Handle(new CreateBoardCommand(), new CancellationToken(), _next.Object);

            _next.Verify(next => next(), Times.Once);
        }
        public async Task Handle_AuthoriserReturnsFalse_ThrowsUnauthorisedApplicationException()
        {
            _authoriser.Setup(a => a.Authorise(It.IsAny <CreateBoardCommand>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(false));
            var authorisers = new List <IAuthorizer <CreateBoardCommand> > {
                _authoriser.Object
            };
            var behaviour = new AuthorizationBehaviour <CreateBoardCommand, BoardCreatedDto>(authorisers);

            Task action() => behaviour.Handle(new CreateBoardCommand(), new CancellationToken(), _next.Object);

            await Assert.ThrowsAsync <UnauthorisedApplicationException>(action);
        }