Example #1
0
        public static IItem GetCustomItem(Item item)
        {
            IItem _item = new StandardItem(item);

            switch (item.Name)
            {
            case "Aged Brie":
                _item = new AgedItem(item);
                break;

            case "Sulfuras, Hand of Ragnaros":
                _item = new LegendaryItem(item);
                break;

            case "Backstage passes to a TAFKAL80ETC concert":
                _item = new PassItem(item);
                break;

            case "Conjured Mana Cake":
                _item = new ConjuredItem(item);
                break;

            default:
                break;
            }

            return(_item);
        }
Example #2
0
        public void QualityOver50Test()
        {
            var item = new LegendaryItem("Sulfuras, Hand of Ragnaros", 0, 80);

            var updater = new LegendaryItemUpdater();

            Assert.Equal(item.Quality, 80);
        }
        public void LegendaryItemDoesNotDecreaseInQualityAndNotHaveToBeSold()
        {
            var name = "Sulfuras, Hand of Ragnaros";
            var Item = new LegendaryItem {
                Name = name
            };

            Assert.That(Item.Quality == 80);
            Assert.That(Item.SellIn == int.MaxValue);
        }
        public void SulfurasNeverDegrades()
        {
            var sulfuras = new LegendaryItem {
                Name = "Sulfuras, Hand of Ragnaros", SellIn = 5, Quality = 10
            };

            updater = new InventoryUpdater(new[] { sulfuras });
            ProcessMany(10);

            Assert.AreEqual(10, sulfuras.Quality);
        }
Example #5
0
        public void Updating_Legendary_Item_Quality_Should_Not_Decrease()
        {
            // Arrange
            var legendaryItem = new  LegendaryItem("Sulfuras, Hand of Ragnaros", 0, 80);

            // Act
            legendaryItem.UpdateQuality();

            // Assert
            Assert.AreEqual(legendaryItem.Quality, 80);
            Assert.AreEqual(legendaryItem.SellIn, 0);
        }
Example #6
0
        public void LegendaryItemUpdateQualityTest()
        {
            var item = new LegendaryItem()
            {
                Quality = 80,
                SellIn  = 0
            };

            item.UpdateQuality();

            Assert.IsTrue(item.Quality == 80 && item.SellIn == -1);
        }
Example #7
0
        public void QualityDoesNotDecreaseTest()
        {
            var item = new LegendaryItem("Sulfuras, Hand of Ragnaros", 0, 80);

            var updater = new LegendaryItemUpdater();

            for (var i = 0; i < 10; i++)
            {
                updater.UpdateItem((item));
            }

            Assert.Equal(item.Quality, 80);
        }
Example #8
0
        public void LegendaryItemsQualityDoesNotDegrade()
        {
            var legendaryItem = new LegendaryItem
            {
                Name    = "Sulfuras",
                SellIn  = 10,
                Quality = 10
            };

            var oldQuality = legendaryItem.Quality;

            ManageInventory.ProcessItem(legendaryItem);

            Assert.AreEqual(oldQuality, legendaryItem.Quality);
        }
Example #9
0
        public void LegendaryItemsSellInDoesNotDecrease()
        {
            var legendaryItem = new LegendaryItem
            {
                Name    = "Sulfuras",
                SellIn  = 10,
                Quality = 10
            };

            var oldSellIn = legendaryItem.SellIn;

            ManageInventory.ProcessItem(legendaryItem);

            Assert.AreEqual(oldSellIn, legendaryItem.SellIn);
        }
Example #10
0
        public void Updating_The_Quality_Of_An_Item_Should_Never_Be_Negative()
        {
            // Arrange
            var commonItem    = new CommonItem("+5 Dexterity Vest", 0, 0);
            var backstageItem = new BackstageItem("Backstage passes to a TAFKAL80ETC concert", 20, 0);
            var agedItem      = new AgedItem("Aged Brie", 2, 0);
            var conjuredItem  = new ConjuredItem("Conjured Mana Cake", 3, 0);
            var legendaryItem = new LegendaryItem("Sulfuras, Hand of Ragnaros", 0, 80);

            // Act
            commonItem.UpdateQuality();
            backstageItem.UpdateQuality();
            agedItem.UpdateQuality();
            conjuredItem.UpdateQuality();
            legendaryItem.UpdateQuality();

            // Assert
            Assert.AreEqual(commonItem.Quality, 0);
            Assert.AreEqual(backstageItem.Quality, 1);
            Assert.AreEqual(agedItem.Quality, 1);
            Assert.AreEqual(conjuredItem.Quality, 0);
            Assert.AreEqual(legendaryItem.Quality, 80);
        }
Example #11
0
        // Run updater for LegendaryItem.
        public void RunUpdater(LegendaryItem item)
        {
            var updater = new LegendaryItemUpdater();

            updater.UpdateItem(item);
        }
Example #12
0
        public LegendaryItem Build()
        {
            var legendaryItem = new LegendaryItem();

            return(legendaryItem);
        }