Ejemplo n.º 1
0
        public async Task Delete_character_command_handler_should_pass()
        {
            // Arrange
            var character = new CharacterBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var command   = new DeleteCharacterCommand {
                Id = character.Id
            };
            var commandHandler = new DeleteCharacterCommandHandler(_testFixture.Context);

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

            // Assert
            response.ShouldBe(Unit.Value);
            character.IsActive.ShouldBe(false);
        }
Ejemplo n.º 2
0
        public async Task Delete_character_command_handler_should_throw_not_found_exception()
        {
            // Arrange
            var character = new CharacterBuilder().Generate().SaveChanges(_testFixture.Context).Build().First();
            var command   = new DeleteCharacterCommand {
                Id = character.Id + 1
            };
            var commandHandler = new DeleteCharacterCommandHandler(_testFixture.Context);

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

            var ex = await Record.ExceptionAsync(Act);

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