public void Post_Success() { // Arrange CashDeskItem item = new CashDeskItem() { Id = "", Name = "Caisse_01" }; _cashDeskServicesMock.Setup(x => x.AddCashDesk(item)) .Verifiable(); _cashDeskFlowValidMock .Setup(x => x.IsValidOperation(BaseValidatorType.Create, It.IsAny <CashDeskItem>(), null)) .Returns(true) .Verifiable(); // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Post(item); // Assert. Assert.IsType <CreatedResult>(actionResult); CreatedResult actionResultType = actionResult as CreatedResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.Created); _cashDeskServicesMock.Verify(); _cashDeskFlowValidMock.Verify(); }
public void Post_ObjectNull() { // Arrange // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Post(null); // Assert. Assert.IsType <BadRequestResult>(actionResult); BadRequestResult actionResultType = actionResult as BadRequestResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); }
public void Post_ObjectIdNotEmpty() { // Arrange CashDeskItem item = new CashDeskItem() { Id = "5c012842f8e2708cf041e247", Name = "Caisse_01" }; // Act CashDeskController controller = new CashDeskController(_cashDeskServicesMock.Object, _cashDeskFlowValidMock.Object); ActionResult actionResult = controller.Post(item); // Assert. Assert.IsType <BadRequestResult>(actionResult); BadRequestResult actionResultType = actionResult as BadRequestResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); }