public async void Should_return_ok() { // Arrange var book = new Book { Title = "The Hobbit", Author = TestAuthorOne, Genre = TestGenreTwo, Rating = 6.6, YearPublished = new DateTime(1939, 1, 1), DateRead = DateTime.Now }; var result = new Result(); result.Errors.Add("there was an error"); BasicBookServiceMock .Setup(x => x.DeleteBookAsync(book.BookId)) .ReturnsAsync(result); // Act var requestResult = await ControllerUnderTest.DeleteBook(book.BookId); // Assert var okResult = Assert.IsType <OkObjectResult>(requestResult); Assert.Same(result, okResult.Value); }
public async void Should_return_result_with_error() { // Arrange var result = new Result(); result.Errors.Add("there was an error"); var book = new Book(); BasicBookServiceMock .Setup(x => x.DeleteBookAsync(book.BookId)) .ReturnsAsync(result); // Act var requestResult = await ControllerUnderTest.DeleteBook(book.BookId); // Assert var okResult = Assert.IsType <OkObjectResult>(requestResult); Assert.Same(result, okResult.Value); }