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 ItemDetail GetTestComboItem(decimal quantity1, decimal quantity2) { var item1InsertResponse = new ItemProxy().InsertItem(GetTestInventoryItem()); var item2InsertResponse = new ItemProxy().InsertItem(GetTestInventoryItem()); var comboItem = GetTestInventoryItem(); comboItem.Type = "C"; comboItem.BuildItems = new List<BuildItem>(){ new BuildItem() { Id = item1InsertResponse.DataObject.InsertedItemId, Quantity = quantity1 }, new BuildItem() { Id = item2InsertResponse.DataObject.InsertedItemId, Quantity = quantity2 } }; return comboItem; }
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 ShouldInsertWhenUsingOauthAuthentication() { var accessToken = TestHelper.SignInAndGetAccessToken(); var comboItem = _itemHelper.GetTestComboItem(); var proxy = new ItemProxy(accessToken); var response = proxy.InsertItem(comboItem); Assert.IsTrue(response.IsSuccessfull); Assert.IsNotNull(response.DataObject); Assert.IsTrue(response.DataObject.InsertedItemId > 0); Assert.GreaterOrEqual(response.DataObject.UtcLastModified, DateTime.Today.AddMinutes(-10).ToUniversalTime()); }
public void ShouldInsertInventoryItem() { var inventoryItem = _itemHelper.GetTestInventoryItem(); var proxy = new ItemProxy(); var response = proxy.InsertItem(inventoryItem); Assert.IsTrue(response.IsSuccessfull); Assert.IsNotNull(response.DataObject); Assert.IsTrue(response.DataObject.InsertedItemId > 0); Assert.GreaterOrEqual(response.DataObject.UtcLastModified, DateTime.Today.AddMinutes(-10).ToUniversalTime()); }
public void ShouldFailOnInsertSaleInventoryItemWithNoSaleAccount() { var inventoryItem = _itemHelper.GetTestInventoryItem(); inventoryItem.SaleIncomeAccountId = null; var proxy = new ItemProxy(); var response = proxy.InsertItem(inventoryItem); Assert.IsFalse(response.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.IsTrue(response.RawResponse.Contains("The Item is marked as 'Sold' and therefore needs to have an Income Account assigned to it.\r\nParameter name: SaleIncomeAccountUid\r\n")); Assert.IsNull(response.DataObject); }
public void ShouldFailOnInsertDuplicateInventoryItemCode() { var inventoryItem = _itemHelper.GetTestInventoryItem(); var proxy = new ItemProxy(); var response1 = proxy.InsertItem(inventoryItem); var response2 = proxy.InsertItem(inventoryItem); Assert.IsTrue(response1.IsSuccessfull); Assert.AreEqual(HttpStatusCode.OK, response1.StatusCode); Assert.IsNotNull(response1.DataObject); Assert.IsFalse(response2.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, response2.StatusCode); Assert.IsTrue(response2.RawResponse.Contains("You already have an item with code")); Assert.IsNull(response2.DataObject); }
public void ShouldFailOnInsertComboItemWithInvalidBuildItem() { var comboItem = _itemHelper.GetTestComboItem(); comboItem.BuildItems.First().Id = 123; var proxy = new ItemProxy(); var response = proxy.InsertItem(comboItem); Assert.IsFalse(response.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.IsTrue(response.RawResponse.Contains("One or more line items of the Combo Item was not found")); Assert.IsNull(response.DataObject); }
public void ShouldFailBuildComboItemDueToStockQuantity() { var proxy = new ItemProxy(); var comboItem = _itemHelper.GetTestComboItem(1, 1); var insertResponse = proxy.InsertItem(comboItem); var response = proxy.BuildItem(insertResponse.DataObject.InsertedItemId, new BuildComboItem() { Quantity = 1 }); Assert.IsFalse(response.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.IsTrue(response.RawResponse.StartsWith("Unable to complete the requested operation as it will cause negative stock-on-hand")); }
public void ShouldFailBuildComboItemDueToNegativeQuantity() { var proxy = new ItemProxy(); var comboItem = _itemHelper.GetTestComboItem(1, 1); var insertResponse = proxy.InsertItem(comboItem); _itemHelper.InventoryAdjustments(comboItem.BuildItems.Select(s => new Tuple<BuildItem, decimal>(s, 10)).ToList()); var response = proxy.BuildItem(insertResponse.DataObject.InsertedItemId, new BuildComboItem() { Quantity = -1 }); Assert.IsFalse(response.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.IsTrue(response.RawResponse.StartsWith("Unable to complete the requested operation as it will cause negative stock-on-hand")); }
public void ShouldFailBuildComboItemDueToBadId() { var proxy = new ItemProxy(); var response = proxy.BuildItem(-1, new BuildComboItem() { Quantity = 1 }); Assert.IsFalse(response.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }
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); }
public void ShouldBuildComboItem() { var proxy = new ItemProxy(); var comboItem = _itemHelper.GetTestComboItem(1,1); var insertResponse = proxy.InsertItem(comboItem); _itemHelper.InventoryAdjustments(comboItem.BuildItems.Select(s => new Tuple<BuildItem, decimal>(s, 10)).ToList()); var response = proxy.BuildItem(insertResponse.DataObject.InsertedItemId, new BuildComboItem() {Quantity = 1}); Assert.IsTrue(response.IsSuccessfull); Assert.IsNotNull(response.DataObject); Assert.AreEqual("1 combo item(s) have been built.", response.DataObject.StatusMessage); Assert.IsNotNull(response.DataObject._links); Assert.IsTrue(response.DataObject._links.Count == 2); }
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 ShouldFailOnInsertComboItemWithNoBuildItems() { var comboItem = _itemHelper.GetTestComboItem(); comboItem.BuildItems = new List<BuildItem>(); var proxy = new ItemProxy(); var response = proxy.InsertItem(comboItem); Assert.IsFalse(response.IsSuccessfull); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); Assert.IsTrue(response.RawResponse.Contains("Please select at least one item for the combo item.")); Assert.IsNull(response.DataObject); }
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; }