Beispiel #1
0
        public void ShouldGetExistingItemAdjustment()
        {
            var itemProxy = new ItemProxy();
            var item      = _itemHelper.GetTestInventoryItem();
            var result    = itemProxy.InsertItem(item);
            var newItem   = itemProxy.GetItem(result.DataObject.InsertedItemId);

            var adjustmentItem = _adjustmentHelper.GetAdjustmentItem(newItem.DataObject.Id.Value, 1,
                                                                     newItem.DataObject.AssetAccountId.Value, 1, 1);

            var detail = _adjustmentHelper.GetAdjustmentDetail(new List <AdjustmentItem>()
            {
                adjustmentItem
            });
            var adjustmentProxy = new ItemAdjustmentProxy();
            var insertResponse  = adjustmentProxy.InsertItemAdjustment(detail);

            var response = adjustmentProxy.GetItemAdjustment(insertResponse.DataObject.InsertedEntityId);

            Assert.IsTrue(response.IsSuccessfull);
            Assert.IsNotNull(response.DataObject);
            Assert.IsTrue(response.DataObject.Id == insertResponse.DataObject.InsertedEntityId);
        }
Beispiel #2
0
        private static bool TryProcessItemMetadata(string segment, [NotNull] ItemProxy proxy)
        {
            if (Item.Quality && Data.Qualities.TryGetValue(segment, out QualityCategory quality))
            {
                proxy.Quality = quality;

                return(true);
            }

            if (Item.Stuff)
            {
                proxy.Stuff = GetItemRaw(segment);
            }

            if (proxy.Stuff != null || proxy.Quality.HasValue)
            {
                return(true);
            }

            proxy.ProcessError = true;

            return(false);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public void ShouldInsertItemAdjustment()
        {
            //var itemCode = "test_w1";
            var itemProxy = new ItemProxy();
            var item      = _itemHelper.GetTestInventoryItem();
            var result    = itemProxy.InsertItem(item);
            var newItem   = itemProxy.GetItem(result.DataObject.InsertedItemId);

            var adjustmentItem = _adjustmentHelper.GetAdjustmentItem(newItem.DataObject.Id.Value, 1,
                                                                     newItem.DataObject.AssetAccountId.Value, 1, 1);

            var detail = _adjustmentHelper.GetAdjustmentDetail(new List <AdjustmentItem>()
            {
                adjustmentItem
            });
            var adjustmentProxy = new ItemAdjustmentProxy();
            var response        = adjustmentProxy.InsertItemAdjustment(detail);

            Assert.IsTrue(response.IsSuccessfull);
            Assert.IsNotNull(response.DataObject);
            Assert.IsTrue(response.DataObject.InsertedEntityId > 0);
            Assert.GreaterOrEqual(response.DataObject.UtcLastModified, DateTime.Today.AddMinutes(-10).ToUniversalTime());
        }
Beispiel #5
0
 protected virtual void AdjustSellIn(ItemProxy item)
 {
     item.DecreaseSellIn();
 }
Beispiel #6
0
 protected override void AdjustSellIn(ItemProxy item)
 {
     // Do nothing
 }
 public override void AdjustQualityForNegativeSellIn(ItemProxy item)
 {
     item.ResetQuality();
 }
Beispiel #8
0
 protected override void AdjustQualityAfterSellInDate(ItemProxy item)
 {
     item.DecreaseQuality();
     item.DecreaseQuality();
 }
Beispiel #9
0
 public override bool IsMatch(ItemProxy item)
 {
     // default rule
     return(true);
 }
Beispiel #10
0
 public override bool IsMatch(ItemProxy item)
 {
     return(item.Name == "Conjured Mana Cake");
 }
Beispiel #11
0
 public override void AdjustQualityForNegativeSellIn(ItemProxy item)
 {
     item.DecrementQuality();
     item.DecrementQuality();
 }
Beispiel #12
0
 protected override void AdjustQualityAfterSellInDate(ItemProxy item)
 {
     item.ResetQuality();
 }
Beispiel #13
0
        private void CreateTestInventoryItems()
        {
            var proxy = new ItemProxy();

            //sale items.
            if (_InventorySaleItemId == 0)
            {
                var result = proxy.InsertItem(new ItemDetail()
                {
                    AssetAccountId         = _AssetAccountId,
                    BuyingPrice            = new decimal(4.00),
                    Code                   = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue           = new decimal(6.00),
                    DefaultReOrderQuantity = 2,
                    Description            = "Test inventory sale item",
                    IsActive               = true,
                    IsBought               = false,
                    IsBuyingPriceIncTax    = false,
                    IsSold                 = true,
                    SaleIncomeAccountId    = _IncomeAccountId,
                    Type                   = "I",
                });

                _InventorySaleItemId = result.DataObject.InsertedItemId;
            }

            if (_InventorySaleItemId2 == 0)
            {
                var result = proxy.InsertItem(new ItemDetail()
                {
                    AssetAccountId         = _AssetAccountId,
                    BuyingPrice            = new decimal(40.00),
                    Code                   = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue           = new decimal(16.00),
                    DefaultReOrderQuantity = 20,
                    Description            = "updated Test inventory sale item",
                    IsActive               = true,
                    IsBought               = false,
                    IsBuyingPriceIncTax    = false,
                    IsSold                 = true,
                    SaleIncomeAccountId    = _IncomeAccountId2,
                    Type                   = "I",
                });

                _InventorySaleItemId2 = result.DataObject.InsertedItemId;
            }

            //purchase items.
            if (_InventoryPurchaseItemId == 0)
            {
                var result = proxy.InsertItem(new ItemDetail()
                {
                    AssetAccountId           = _AssetAccountId,
                    BuyingPrice              = new decimal(4.00),
                    Code                     = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue             = new decimal(6.00),
                    DefaultReOrderQuantity   = 2,
                    Description              = "Test inventory purchase item",
                    IsActive                 = true,
                    IsBought                 = true,
                    IsBuyingPriceIncTax      = true,
                    PurchaseExpenseAccountId = _ExpenseAccountId,
                    Type                     = "I",
                });

                _InventoryPurchaseItemId = result.DataObject.InsertedItemId;
            }

            if (_InventoryPurchaseItemId2 == 0)
            {
                var result = proxy.InsertItem(new ItemDetail()
                {
                    AssetAccountId           = _AssetAccountId,
                    BuyingPrice              = new decimal(40.00),
                    Code                     = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue             = new decimal(60.00),
                    DefaultReOrderQuantity   = 20,
                    Description              = "Updated test inventory purchase item",
                    IsActive                 = true,
                    IsBought                 = true,
                    IsBuyingPriceIncTax      = true,
                    PurchaseExpenseAccountId = _ExpenseAccountId2,
                    Type                     = "I",
                });

                _InventoryPurchaseItemId2 = result.DataObject.InsertedItemId;
            }
        }
Beispiel #14
0
 protected override void AdjustQualityAfterSellInDate(ItemProxy item)
 {
     // Do nothing
 }
Beispiel #15
0
 protected abstract void AdjustQualityAfterSellInDate(ItemProxy item);
Beispiel #16
0
 public override bool IsMatch(ItemProxy item)
 {
     return(item.Name == "Aged Brie");
 }
Beispiel #17
0
        public bool TryGetNextAsItem(out ItemProxy item)
        {
            item = GetNextAsItem();

            return(!(item is null));
        }
Beispiel #18
0
 public override void AdjustSellIn(ItemProxy item)
 {
     // do nothing
 }
Beispiel #19
0
 public override void AdjustQualityForNegativeSellIn(ItemProxy item)
 {
     // do nothing
 }
Beispiel #20
0
 public override void AdjustQuality(ItemProxy item)
 {
     item.DecrementQuality();
 }
Beispiel #21
0
 public override bool IsMatch(ItemProxy item)
 {
     return(item.Name == "Sulfuras, Hand of Ragnaros");
 }
Beispiel #22
0
 protected override void AdjustQuality(ItemProxy item)
 {
     item.DecreaseQuality();
     item.DecreaseQuality();
 }
Beispiel #23
0
 public override void AdjustQuality(ItemProxy item)
 {
     // do nothing
 }
Beispiel #24
0
        public void UpdateQuality(ItemProxy item)
        {
            switch (item.Name)
            {
            case "Aged Brie":
                item.IncrementQuality();

                if (item.SellIn <= 0)
                {
                    item.IncrementQuality();
                }
                item.DecreaseSellIn();
                break;

            case "Sulfuras, Hand of Ragnaros":
                break;

            case "Backstage passes to a TAFKAL80ETC concert":
                item.IncrementQuality();

                if (item.SellIn <= 10)
                {
                    item.IncrementQuality();
                }
                if (item.SellIn <= 5)
                {
                    item.IncrementQuality();
                }
                if (item.SellIn <= 0)
                {
                    item.ResetQuality();
                }

                item.DecreaseSellIn();
                break;

            case "Conjured hat":
                item.DecreaseQuality();
                item.DecreaseQuality();

                if (item.SellIn <= 0)
                {
                    item.DecreaseQuality();
                    item.DecreaseQuality();
                }

                item.DecreaseSellIn();
                break;

            default:
                item.DecreaseQuality();

                if (item.SellIn <= 0)
                {
                    item.DecreaseQuality();
                }

                item.DecreaseSellIn();
                break;
            }
        }
Beispiel #25
0
 protected abstract void AdjustQuality(ItemProxy item);
 public override bool IsMatch(ItemProxy item)
 {
     return(item.Name == "Backstage passes to a TAFKAL80ETC concert");
 }
Beispiel #27
0
 protected override void AdjustQuality(ItemProxy item)
 {
     // Do nothing
 }