public async Task DeleteOk() { var serviceMock = new Mock <IContaService>(); serviceMock.Setup(m => m.Delete(It.IsAny <Guid>())) .ReturnsAsync(true); _controller = new ContasController(serviceMock.Object); var result = await _controller.Delete(Guid.NewGuid()); Assert.True(result is OkObjectResult); }
public void Controller_Contas_Delete_DevePassar() { // Arrange var isUpdated = true; _contaServiceMock.Setup(c => c.Delete(_contaRemoveCmd.Object)).Returns(isUpdated); // Action IHttpActionResult callback = _contasController.Delete(_contaRemoveCmd.Object); // Assert var httpResponse = callback.Should().BeOfType <OkNegotiatedContentResult <bool> >().Subject; _contaServiceMock.Verify(s => s.Delete(_contaRemoveCmd.Object), Times.Once); httpResponse.Content.Should().BeTrue(); }
public async Task DeleteBadRequest() { var serviceMock = new Mock <IContaService>(); serviceMock.Setup(m => m.Delete(It.IsAny <Guid>())) .ReturnsAsync(true); _controller = new ContasController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato Inválido"); var result = await _controller.Delete(Guid.NewGuid()); Assert.True(result is BadRequestObjectResult); }