public void Put_Success() { // Arrange CashDeskItem item = new CashDeskItem() { Id = "5c012842f8e2708cf041e247", Name = "Caisse_01" }; _cashDeskServicesMock.Setup(x => x.GetCashDesk(item.Id)).Returns(Task.FromResult(item)); _cashDeskServicesMock.Setup(x => x.UpdateCashDesk(item.Id, item)) .ReturnsAsync(true) .Verifiable(); _cashDeskFlowValidMock .Setup(x => x.IsValidOperation(BaseValidatorType.Update, It.IsAny <CashDeskItem>(), It.IsAny <CashDeskItem>())) .Returns(true) .Verifiable(); // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Put(item); // Assert. Assert.IsType <AcceptedResult>(actionResult); AcceptedResult actionResultType = actionResult as AcceptedResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.Accepted); _cashDeskServicesMock.Verify(); _cashDeskFlowValidMock.Verify(); }
public void Put_ObjectNull() { // Arrange // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Put(null); // Assert. Assert.IsType <BadRequestResult>(actionResult); BadRequestResult actionResultType = actionResult as BadRequestResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); }
public void Put_ObjectIdEmpty() { // Arrange CashDeskItem item = new CashDeskItem() { Id = "", Name = "Caisse_01" }; // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Put(item); // Assert. Assert.IsType <BadRequestResult>(actionResult); BadRequestResult actionResultType = actionResult as BadRequestResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); }