Ejemplo n.º 1
0
        public void VerifyItemsHaveDeteriorated()
        {
            var items = _itemProcessor.GetItems();

            var itemNames = new List <string>
            {
                "Dexterity Vest",
                "Mongoose"
            };

            foreach (var name in itemNames)
            {
                var item = items.FirstOrDefault(i => i.Name.Contains(name));
                item.ShouldNotBe(null);

                var initialQuality = item.Quality;
                var initialSellIn  = item.SellIn;

                _itemProcessor.UpdateQuality();

                var after = items.FirstOrDefault(i => i.Name.Contains(name));
                after.ShouldNotBe(null);

                after.Quality.ShouldBe(initialQuality - 1);
                after.SellIn.ShouldBe(initialSellIn - 1);
            }
        }
Ejemplo n.º 2
0
        public void VerifyBrieHasChanged()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = Constants.ProductNames.AgedBrie,
                    Quality = 0,
                    SellIn  = 2
                }
            };

            var initialQuality = items[0].Quality;
            var initialSellIn  = items[0].SellIn;
            var itemProcessor  = new ItemProcessor(items);

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();
            var item        = updateItems.FirstOrDefault(i => i.Name.Contains(Constants.ProductNames.AgedBrie));

            item.ShouldNotBe(null);
            item.Quality.ShouldBe(initialQuality + 1);
            item.SellIn.ShouldBe(initialSellIn - 1);
        }
Ejemplo n.º 3
0
        public void ConjuredItemsDegradeTwiceAsFast()
        {
            var items = new List <Item>
            {
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 3, Quality = 6
                }
            };

            var itemProcessor  = new ItemProcessor(items);
            var initialQuality = items[0].Quality;

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();

            updateItems[0].Quality.ShouldBe(initialQuality - 2);
        }
Ejemplo n.º 4
0
        public void BackStagePassesQualityHitsZero()
        {
            // Quality drops to 0 after the concert
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    Quality = 5,
                    SellIn  = 0
                }
            };

            var itemProcessor = new ItemProcessor(items);

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();

            updateItems[0].Quality.ShouldBe(0);
        }
Ejemplo n.º 5
0
        public void WhenSellByDateHasNotPassedQualityDegradesNormally()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "+2 Mace of Smiting",
                    Quality = 7,
                    SellIn  = 2
                }
            };

            var itemProcessor  = new ItemProcessor(items);
            var initialQuality = items[0].Quality;

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();

            updateItems[0].Quality.ShouldBe(initialQuality - 1);
        }
Ejemplo n.º 6
0
        public void BackStagePassesQualityIncreasesBy3When5DaysAway()
        {
            // Quality increases by 3 when there are 5 days or less
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    Quality = 5,
                    SellIn  = 5
                }
            };

            var itemProcessor  = new ItemProcessor(items);
            var initialQuality = items[0].Quality;

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();

            updateItems[0].Quality.ShouldBe(initialQuality + 3);
        }
Ejemplo n.º 7
0
        public void ItemQualityMaxIs50()
        {
            //The Quality of an item is never more than 50
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "+2 Mace of Smiting",
                    Quality = 50,
                    SellIn  = 2
                }
            };

            var itemProcessor  = new ItemProcessor(items);
            var initialQuality = items[0].Quality;

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();

            updateItems[0].Quality.ShouldBe(initialQuality);
        }
Ejemplo n.º 8
0
        public void QualityOfItemIsNeverNegative()
        {
            // The Quality of an item is never negative
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "+2 Mace of Smiting",
                    Quality = 0,
                    SellIn  = 2
                }
            };

            var itemProcessor  = new ItemProcessor(items);
            var initialQuality = items[0].Quality;

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();

            updateItems[0].Quality.ShouldBe(initialQuality);
        }
Ejemplo n.º 9
0
        public void WhenSellByDatePassedQualityDegradesTwiceAsFast()
        {
            //Once the sell by date has passed, Quality degrades twice as fast
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "+2 Mace of Smiting",
                    Quality = 7,
                    SellIn  = 0
                }
            };

            var itemProcessor  = new ItemProcessor(items);
            var initialQuality = items[0].Quality;

            itemProcessor.UpdateQuality();

            var updateItems = itemProcessor.GetItems();

            updateItems[0].Quality.ShouldBe(initialQuality - 2);
        }