Exemple #1
0
        public async Task Delete_episode_command_handler_should_pass()
        {
            // Arrange
            var episode = new EpisodeBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var command = new DeleteEpisodeCommand {
                Id = episode.Id
            };
            var commandHandler = new DeleteEpisodeCommandHandler(_testFixture.Context);

            // Act
            var response = await commandHandler.Handle(command, CancellationToken.None);

            // Assert
            response.ShouldBe(Unit.Value);
            episode.IsActive.ShouldBe(false);
        }
Exemple #2
0
        public async Task Delete_episode_command_handler_should_throw_not_found_exception()
        {
            // Arrange
            var episode = new EpisodeBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var command = new DeleteEpisodeCommand {
                Id = episode.Id + 1
            };
            var commandHandler = new DeleteEpisodeCommandHandler(_testFixture.Context);

            // Act
            async Task Act() => await commandHandler.Handle(command, CancellationToken.None);

            var ex = await Record.ExceptionAsync(Act);

            // Assert
            ex.ShouldBeOfType <NotFoundException>();
        }