public async void Should_return_ok() { // Arrange var book = new Book { Title = "Some book", }; var result = new Result(); AddBookCommandMock .Setup(x => x.Execute(book)) .ReturnsAsync(result); // Act var serviceResult = await ServiceUnderTest.AddBookAsync(book); // Assert Assert.Same(result, serviceResult); Assert.NotNull(serviceResult); }
public async void Should_return_error_with_message() { // Arrange var book = new Book { Title = "Some book", }; var result = new Result(); result.AddError("there was an error"); AddBookCommandMock .Setup(x => x.Execute(book)) .ReturnsAsync(result); // Act var serviceResult = await ServiceUnderTest.AddBookAsync(book); // Assert Assert.Same(result, serviceResult); Assert.NotNull(serviceResult); Assert.Equal(result.Errors.First(), serviceResult.Errors.First()); }