Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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));
        }