public async Task Handle_GivenValidRequest_ShouldTransferTeamOwnership()
        {
            // Arrange
            var command = new TransferTeamOwnershipCommand {
                PlayerId = "Foo5", TeamId = 1
            };

            var userAccessorMock = new Mock <IUserAccessor>();

            userAccessorMock.Setup(x => x.UserId).Returns("Foo1");

            var sut = new TransferTeamOwnershipCommandHandler(this.deletableEntityRepository, userAccessorMock.Object);

            var team = this.dbContext.Teams.SingleOrDefault(x => x.Id == 1);

            team.PlayerTeams.Add(new PlayerTeam {
                PlayerId = "Foo5", TeamId = 1
            });
            this.dbContext.SaveChanges();

            // Act
            var affectedRows = await sut.Handle(command, It.IsAny <CancellationToken>());

            // Assert
            affectedRows.ShouldBeGreaterThan(0);
            team.OwnerId.ShouldBe("Foo5");
        }
        public async Task Handle_GivenNullRequest_ShouldThrowArgumentNullException()
        {
            // Arrange
            var sut = new TransferTeamOwnershipCommandHandler(It.IsAny <IDeletableEntityRepository <Team> >(), It.IsAny <IUserAccessor>());

            // Act & Assert
            await Should.ThrowAsync <ArgumentNullException>(sut.Handle(null, It.IsAny <CancellationToken>()));
        }
        public async Task Handle_GivenInvalidRequest_ShouldThrowNotFoundException()
        {
            // Arrange
            var command = new TransferTeamOwnershipCommand {
                PlayerId = "Foo5", TeamId = 131
            };
            var sut = new TransferTeamOwnershipCommandHandler(this.deletableEntityRepository, It.IsAny <IUserAccessor>());

            // Act & Assert
            await Should.ThrowAsync <NotFoundException>(sut.Handle(command, It.IsAny <CancellationToken>()));
        }
        public async Task Handle_GivenInvalidRequest_ShouldThrowPlayerIsNotAMemberOfTeam()
        {
            // Arrange
            var command = new TransferTeamOwnershipCommand {
                PlayerId = "Foo4", TeamId = 1
            };

            var userAccessorMock = new Mock <IUserAccessor>();

            userAccessorMock.Setup(x => x.UserId).Returns("Foo1");

            var sut = new TransferTeamOwnershipCommandHandler(this.deletableEntityRepository, userAccessorMock.Object);

            // Act & Assert
            await Should.ThrowAsync <PlayerIsNotAMemberOfTeamException>(sut.Handle(command, It.IsAny <CancellationToken>()));
        }