コード例 #1
0
        public void Handler_GivenInvalidAuthorId_ThrowsException()
        {
            // Arrange
            var invalidAuthorId = 99;

            // Act
            var command = new DeleteAuthorCommand {
                Id = invalidAuthorId
            };
            var handler = new DeleteAuthorCommand.DeleteAuthorCommandHandler(Context);

            // Assert
            Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None));
        }
コード例 #2
0
        public async Task Handler_GivenValidAuthorId_ShouldRemoveAuthor()
        {
            // Arrange
            var validAuthorId = 3;

            // Act
            var command = new DeleteAuthorCommand {
                Id = validAuthorId
            };
            var handler = new DeleteAuthorCommand.DeleteAuthorCommandHandler(Context);
            await handler.Handle(command, CancellationToken.None);

            // Assert
            var entity = Context.Authors.Find(command.Id);

            entity.ShouldBeNull();
        }