public async Task ReturnBadRequestWhenModelNotValid() { // Arrange _controller.ModelState.AddModelError("someFakeError", "fakeError message"); // Act var result = await _controller.Delete(1); // Assert result.Should().BeOfType <BadRequestResult>(); var model = result as BadRequestResult; }
public async Task ReturnOkWhenDeletedData() { // Arrange int id = 1; bool expected = true; _mockService.Setup(x => x.Delete(It.IsAny <int>())) .ReturnsAsync(expected) .Verifiable(); // Act var result = await _controller.Delete(id); // Assert result.Should().BeOfType <OkObjectResult>(); var model = result as OkObjectResult; model?.Value.Should().Be(expected); }