public async Task DeleteShouldReturnOkResultWithModelId() { // Arrange var model = new Flight(); var fakeSql = Substitute.For<IDatabase>(); fakeSql.DeleteAsync(model).ReturnsForAnyArgs(Task.FromResult(true)); var controller = new FlightsController(fakeSql); // Act var result = await controller.Delete(1); // Assert var viewResult = Assert.IsType<OkNegotiatedContentResult<int>>(result); Assert.Equal(viewResult.Content, 1); }
public async Task DeleteShouldReturnBadRequestResultWhenResultFalse() { // Arrange var model = new Flight(); var fakeSql = Substitute.For<IDatabase>(); fakeSql.DeleteAsync(model).ReturnsForAnyArgs(Task.FromResult(false)); var controller = new FlightsController(fakeSql); // Act var result = await controller.Delete(1); // Assert var viewResult = Assert.IsType<BadRequestResult>(result); Assert.NotNull(viewResult); }