Beispiel #1
0
        public async Task DeleteBookCommand_should_return_call_Delete_repository_method()
        {
            // Arrange

            // Act
            await _handler.Handle(new DeleteBookCommand(Guid.Empty), default);

            // Assert
            A.CallTo(() => _repository.Delete(A <Guid> .Ignored)).MustHaveHappenedOnceExactly();
        }
Beispiel #2
0
        public async Task Delete_Book()
        {
            using (var context = GetContextWithData())
            {
                var handler = new DeleteBookCommandHandler(context);
                var command = new DeleteBookCommand
                {
                    Id = (await context.Books.FirstOrDefaultAsync()).Id
                };

                await handler.Handle(command, CancellationToken.None);

                Assert.Null(await context.Books.FindAsync(command.Id));
            }
        }