public async Task Delete_log_error_sucess(int id) { //Arrange var response = new Response <int>(id, true); _logErrorServiceMock.Setup(x => x.RemoveAsync(id)) .Returns(Task.FromResult(response)); //Act var logErrorController = new LogErrorsController(_logErrorServiceMock.Object, _loggerMock.Object); var actionResult = await logErrorController.DeleteAsync(id); //Assert var okRequestResult = Assert.IsType <OkObjectResult>(actionResult.Result); okRequestResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var result = Assert.IsType <Response <int> >(okRequestResult.Value); result.Should() .BeEquivalentTo(response); }
public async Task Delete_log_error_bad_request(int id) { //Arrange var response = new Response <int>(id, false, new[] { $"object with id {id} not found" }); _logErrorServiceMock.Setup(x => x.RemoveAsync(id)) .Returns(Task.FromResult(response)); //Act var logErrorController = new LogErrorsController(_logErrorServiceMock.Object, _loggerMock.Object); var actionResult = await logErrorController.DeleteAsync(id); //Assert var badRequestResult = Assert.IsType <BadRequestObjectResult>(actionResult.Result); badRequestResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); var result = Assert.IsType <Response <int> >(badRequestResult.Value); result.Should() .BeEquivalentTo(response); }