public void GetInventoryItemById() { var itemsProxy = new ItemsProxy(); var inventoryAndComboItemResponse = itemsProxy.GetItems("I", null, null, 0, 25); Assert.IsTrue(inventoryAndComboItemResponse.IsSuccessfull && inventoryAndComboItemResponse.DataObject.Items.Count > 0, "Cannot continue test, request for items failed or returned no items"); var existingInventoryItemId = inventoryAndComboItemResponse.DataObject.Items.First().Id; var itemProxy = new ItemProxy(); var inventoryItemResponse = itemProxy.GetItem(existingInventoryItemId.Value); Assert.IsTrue(inventoryItemResponse.IsSuccessfull, "Unsuccessful request."); var inventoryItem = inventoryItemResponse.DataObject; Assert.IsNotNull(inventoryItem, "No inventory item found."); Assert.IsTrue(inventoryItem.Type == "I", "Invalid item type."); Assert.IsTrue(inventoryItem.LastModifiedDateUtc.HasValue); Assert.AreNotEqual(DateTime.MinValue, inventoryItem.LastModifiedDateUtc.Value); Assert.IsTrue(inventoryItem.CreatedDateUtc.HasValue); Assert.AreNotEqual(DateTime.MinValue, inventoryItem.CreatedDateUtc.Value); }
public void ShouldUpdateExistingInventoryItem() { var inventoryItem = _itemHelper.GetTestInventoryItem(); var proxy = new ItemProxy(); var insertResponse = proxy.InsertItem(inventoryItem); Assert.IsTrue(insertResponse.IsSuccessfull); Assert.IsTrue(insertResponse.DataObject.InsertedItemId > 0); var getResponse = proxy.GetItem(insertResponse.DataObject.InsertedItemId); var retrievedItem = getResponse.DataObject; Assert.IsTrue(getResponse.IsSuccessfull); Assert.AreEqual(inventoryItem.Description, retrievedItem.Description); retrievedItem.Description = "Updated Item " + Guid.NewGuid(); var updateResponse = proxy.UpdateItem(retrievedItem, retrievedItem.Id.Value); Assert.IsTrue(updateResponse.IsSuccessfull); Assert.AreEqual(insertResponse.DataObject.InsertedItemId, updateResponse.DataObject.UpdatedItemId); var updatedItem = proxy.GetItem(updateResponse.DataObject.UpdatedItemId); Assert.AreEqual(retrievedItem.Description, updatedItem.DataObject.Description); }
public void ShouldUpdateExistingComboItemBuildItem() { var comboItem = _itemHelper.GetTestComboItem(); var proxy = new ItemProxy(); var insertResponse = proxy.InsertItem(comboItem); Assert.IsTrue(insertResponse.IsSuccessfull); Assert.IsTrue(insertResponse.DataObject.InsertedItemId > 0); var getResponse = proxy.GetItem(insertResponse.DataObject.InsertedItemId); var retrievedComboItem = getResponse.DataObject; Assert.IsTrue(getResponse.IsSuccessfull); Assert.AreEqual(comboItem.Description, retrievedComboItem.Description); retrievedComboItem.BuildItems.OrderBy(x => x.Code).First().Quantity = 99; var updateResponse = proxy.UpdateItem(retrievedComboItem, retrievedComboItem.Id.Value); Assert.IsTrue(updateResponse.IsSuccessfull); Assert.AreEqual(insertResponse.DataObject.InsertedItemId, updateResponse.DataObject.UpdatedItemId); var updatedItem = proxy.GetItem(updateResponse.DataObject.UpdatedItemId); Assert.AreEqual(retrievedComboItem.BuildItems.OrderBy(x => x.Code).First().Quantity, updatedItem.DataObject.BuildItems.OrderBy(x => x.Code).First().Quantity); }
public void ShouldReplaceExistingComboItemBuildItem() { var comboItem = _itemHelper.GetTestComboItem(); var proxy = new ItemProxy(); var insertResponse = proxy.InsertItem(comboItem); Assert.IsTrue(insertResponse.IsSuccessfull); Assert.IsTrue(insertResponse.DataObject.InsertedItemId > 0); var getResponse = proxy.GetItem(insertResponse.DataObject.InsertedItemId); var retrievedComboItem = getResponse.DataObject; var inventoryItem = _itemHelper.GetTestInventoryItem(); var insertNewItemResponse = proxy.InsertItem(inventoryItem); Assert.IsTrue(insertNewItemResponse.IsSuccessfull); retrievedComboItem.BuildItems.RemoveAt(0); retrievedComboItem.BuildItems.Add(new BuildItem { Id = insertNewItemResponse.DataObject.InsertedItemId, Quantity = 444 }); var updateResponse = proxy.UpdateItem(retrievedComboItem, retrievedComboItem.Id.Value); Assert.IsTrue(updateResponse.IsSuccessfull); Assert.AreEqual(insertResponse.DataObject.InsertedItemId, updateResponse.DataObject.UpdatedItemId); var updatedItem = proxy.GetItem(updateResponse.DataObject.UpdatedItemId); Assert.AreEqual(2, retrievedComboItem.BuildItems.Count); Assert.IsTrue(retrievedComboItem.BuildItems.Any(x => x.Id == insertNewItemResponse.DataObject.InsertedItemId)); }
public void ShouldDeleteInventoryItem() { var proxy = new ItemProxy(); var item = _itemHelper.GetTestInventoryItem(); var insertResponse = proxy.InsertItem(item); Assert.IsTrue(insertResponse.IsSuccessfull); var deleteResponse = proxy.DeleteItem(insertResponse.DataObject.InsertedItemId); Assert.IsTrue(deleteResponse.IsSuccessfull); Assert.AreEqual(HttpStatusCode.OK, deleteResponse.StatusCode); var getResponse = proxy.GetItem(insertResponse.DataObject.InsertedItemId); Assert.IsFalse(getResponse.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, getResponse.StatusCode); }
private ItemDetail InsertAndGetInventoryItem() { var itemProxy = new ItemProxy(); var inventoryItem = _itemHelper.GetTestInventoryItem(); var itemResponse = itemProxy.InsertItem(inventoryItem); var item = itemProxy.GetItem(itemResponse.DataObject.InsertedItemId); Assert.IsNotNull(item.DataObject, "Failed to insert and retrieve inventory item"); Thread.Sleep(2000); return item.DataObject; }