public void Get_All_Success() { // Arrange CheckOutItem item = new CheckOutItem() { Id = "5c012842f8e2708cf041e247" }; IEnumerable <CheckOutItem> items = new List <CheckOutItem>() { item }; _checkOutServicesMock.Setup(x => x.GetCheckOutList()).Returns(Task.FromResult(items)); // Act CheckOutController controller = new CheckOutController(_checkOutServicesMock.Object, _eventBusMock.Object, _checkOutFlowValidMock.Object); ActionResult actionResult = controller.Get().Result; // Assert. Assert.IsType <OkObjectResult>(actionResult); OkObjectResult actionResultType = actionResult as OkObjectResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.OK); Assert.Equal(((List <CheckOutItem>)actionResultType.Value), ((List <CheckOutItem>)items.ToList())); }
public void Get_Id_IdError() { // Arrange string fakeId = "this_is_not_a_id"; CheckOutItem item = new CheckOutItem() { Id = "5c012842f8e2708cf041e247" }; _checkOutServicesMock.Setup(x => x.GetCheckOut(item.Id)).Returns(Task.FromResult(item)); // Act CheckOutController controller = new CheckOutController(_checkOutServicesMock.Object, _eventBusMock.Object, _checkOutFlowValidMock.Object); ActionResult actionResult = controller.Get(fakeId).Result; // Assert. Assert.IsType <NotFoundResult>(actionResult); NotFoundResult actionResultType = actionResult as NotFoundResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.NotFound); }
public void Get_Id_Success() { // Arrange string fakeId = "5c012842f8e2708cf041e247"; CheckOutItem item = new CheckOutItem() { Id = "5c012842f8e2708cf041e247" }; _checkOutServicesMock.Setup(x => x.GetCheckOut(item.Id)).Returns(Task.FromResult(item)); // Act CheckOutController controller = new CheckOutController(_checkOutServicesMock.Object, _eventBusMock.Object, _checkOutFlowValidMock.Object); ActionResult actionResult = controller.Get(fakeId).Result; // Assert. Assert.IsType <OkObjectResult>(actionResult); OkObjectResult actionResultType = actionResult as OkObjectResult; Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.OK); Assert.Equal(((CheckOutItem)actionResultType.Value), item); }