public void Delete_Success() { // Arrange CashDeskItem item = new CashDeskItem() { Id = "5c012842f8e2708cf041e247", Name = "Caisse_01" }; Acknowledged deleteResult = new Acknowledged(1); _cashDeskServicesMock.Setup(x => x.GetCashDesk(item.Id)).Returns(Task.FromResult(item)); _cashDeskServicesMock.Setup(x => x.DeleteCashDesk(item.Id)) .ReturnsAsync(deleteResult) .Verifiable(); _cashDeskFlowValidMock .Setup(x => x.IsValidOperation(BaseValidatorType.Delete, It.IsAny <CashDeskItem>(), null)) .Returns(true) .Verifiable(); // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Delete(item.Id); // Assert. Assert.IsType <NoContentResult>(actionResult); NoContentResult actionResultType = actionResult as NoContentResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.NoContent); _cashDeskServicesMock.Verify(); _cashDeskFlowValidMock.Verify(); }
public void Delete_IdEmpty() { // Arrange // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Delete(string.Empty); // Assert. Assert.IsType <BadRequestResult>(actionResult); BadRequestResult actionResultType = actionResult as BadRequestResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); _cashDeskServicesMock.Verify(); }