public void WarehouseReturnsPendingWhenBuyingItemsInStock() { var items = TestData.CreateTestData(); var cntItems = items.Count(); var c = new ItemsController(new Repository(items)); setupItemsController(c); var request = new AcquisitionRequest { Account = null, ProductName = "Item a", Quantity = 1 }; IHttpActionResult actionResult = c.Buy(request); var contentResult = actionResult as OkNegotiatedContentResult <AcquisitionResponse>; Assert.IsNotNull(contentResult); var result = contentResult.Content; Assert.AreEqual(RequestStatus.Pending, result.RepositoryResponse.Status); Assert.IsNotNull(result.RepositoryResponse.ReceiptID); Assert.IsNotNull(result.UrlToCheckStatusAt); }
public void GetStatusReturnsExpectedValues() { var items = TestData.CreateTestData(); var cntItems = items.Count(); var c = new ItemsController(new Repository(items)); setupItemsController(c); var request = new AcquisitionRequest { Account = null, ProductName = "Item a", Quantity = 1 }; IHttpActionResult actionResult = c.Buy(request); var contentResult = actionResult as OkNegotiatedContentResult <AcquisitionResponse>; var receiptId = contentResult.Content.RepositoryResponse.ReceiptID; IHttpActionResult statusResult = c.GetStatus(receiptId); var statusResponse = statusResult as OkNegotiatedContentResult <AcquisitionResponse>; var content = statusResponse.Content; Assert.AreEqual(RequestStatus.Pending, content.RepositoryResponse.Status); Assert.IsNotNull(content.RepositoryResponse.ReceiptID); Assert.IsNotNull(content.UrlToCheckStatusAt); }
public void WarehouseReturnsNotFoundWhenBuyingItemsOutOfStock() { var items = TestData.CreateTestData(); var cntItems = items.Count(); var c = new ItemsController(new Repository(items)); setupItemsController(c); var request = new AcquisitionRequest { Account = null, ProductName = "Item d", Quantity = 1 }; IHttpActionResult actionResult = c.Buy(request); Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }