public async void DeleteSurvey_UnknownId_ReturnsBadRequestResult() { // Arrange var mock = new Mock <ISurveyService>(); mock.Setup(s => s.DeleteAsync(It.IsAny <int>())).Returns((int id) => FakeServicesMethods.DeleteSurvey(id)); var controller = new SurveyController(mock.Object); // Act var result = await controller.DeleteSurvey(0); var badRequestResult = result as BadRequestResult; // Assert Assert.NotNull(badRequestResult); }
public async void DeleteSurvey_CorrectId_ReturnsOk() { // Arrange var mock = new Mock <ISurveyService>(); mock.Setup(s => s.DeleteAsync(It.IsAny <int>())).Returns((int id) => FakeServicesMethods.DeleteSurvey(id)); var controller = new SurveyController(mock.Object); // Act var result = await controller.DeleteSurvey(1); var okResult = result as OkResult; // Assert Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); }