protected async Task Delete(int id, string expectedResultName, BaseController <T> controller) { // Act var response = await controller.Delete(id); // Assert Assert.True(response.Result.GetType().Name == expectedResultName, $"It was expected that this test case would have a '{expectedResultName}' return, however it did not. Actual result type: {response.Result.GetType()}."); }
public void DeleteUserById() { var baseRepository = _controllerFixture.Setup(); _baseController = new BaseController <User>(baseRepository.Object); baseRepository.Setup(x => x.Delete(1)); _baseController.Delete(5); User userToDelete = _controllerFixture.Users.Find(x => x.ID == 5); _controllerFixture.Users.Remove(userToDelete); Assert.Equal(3, _controllerFixture.Users.Count); }
public void Should_return_no_content_when_delete_called() { var result = _userController.Delete(1234); Assert.IsInstanceOf <NoContentResult>(result); }
// DELETE: api/projects/5 public void Delete(int id) { baseRepo.Delete(id, repo); }