Exemplo n.º 1
0
        public async Task Handle_GivenNullRequest_ShouldThrowArgumentNullException()
        {
            // Arrange
            var sut = new DeleteTournamentCommandHandler(It.IsAny <IDeletableEntityRepository <Tournament> >());

            // Act & Assert
            await Should.ThrowAsync <ArgumentNullException>(sut.Handle(null, It.IsAny <CancellationToken>()));
        }
Exemplo n.º 2
0
        public async Task Handle_GivenInvalidRequest_ShouldThrowNotFoundException()
        {
            // Arrange
            var command = new DeleteTournamentCommand {
                Id = 333
            };
            var sut = new DeleteTournamentCommandHandler(this.deletableEntityRepository);

            // Act & Assert
            await Should.ThrowAsync <NotFoundException>(sut.Handle(command, It.IsAny <CancellationToken>()));
        }
Exemplo n.º 3
0
        public async Task Handle_GivenValidRequest_ShouldDeleteEntity()
        {
            // Arrange
            var command = new DeleteTournamentCommand {
                Id = 2
            };
            var sut = new DeleteTournamentCommandHandler(this.deletableEntityRepository);

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

            // Assert
            id.ShouldBeGreaterThan(0);

            var deletedTournament = this.deletableEntityRepository.AllAsNoTrackingWithDeleted().SingleOrDefault(x => x.Id == 2);

            deletedTournament.IsDeleted.ShouldBe(true);
        }