Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");

            var app = new Inn()
            {
                Items = new List<Item>
                                          {
                                              new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                                              new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
                                              new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                                              new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
                                              new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80},
                                              new Item
                                                  {
                                                      Name = "Backstage passes to a TAFKAL80ETC concert",
                                                      SellIn = 15,
                                                      Quality = 20
                                                  },
                                              new Item
                                                  {
                                                      Name = "Backstage passes to a TAFKAL80ETC concert",
                                                      SellIn = 10,
                                                      Quality = 49
                                                  },
                                              new Item
                                                  {
                                                      Name = "Backstage passes to a TAFKAL80ETC concert",
                                                      SellIn = 5,
                                                      Quality = 49
                                                  },
                                              // this conjured item does not work properly yet
                                              new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
                                          }

            };

            for (var i = 0; i < 31; i++)
            {
                System.Console.WriteLine("-------- day " + i + " --------");
                System.Console.WriteLine("name, sellIn, quality");
                for (var j = 0; j < app.Items.Count; j++)
                {
                    System.Console.WriteLine(app.Items[j].Name + ", " + app.Items[j].SellIn + ", " + app.Items[j].Quality);
                }
                System.Console.WriteLine("");
                app.UpdateQualityAndSellInAfterADay();
            }
            System.Console.ReadKey();
        }
Example #2
0
        public void TestUpdateQualityBackstageIncreaseQualityBy3When5DaysLeftOrLessAndSellInPositive()
        {
            //actor
            IList<Item> itemsOrigin = GetBackstageIncreaseQualityBy3When5DaysLeftOrLessAndSellInPositive();
            Inn inn = new Inn()
            {
                Items = GetBackstageIncreaseQualityBy3When5DaysLeftOrLessAndSellInPositive()
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            int numItem = 0;
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin[numItem];
                Assert.AreEqual(itemOrigin.Quality + 3, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn - 1, itemCourant.SellIn);
                numItem++;
            }
        }
Example #3
0
        public void TestUpdateQualityBackstageDropTo0AfterConcert()
        {
            //actor
            IList<Item> itemsOrigin = GetBackstageWithSellIn0();
            Inn inn = new Inn()
            {
                Items = GetBackstageWithSellIn0()
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            int numItem = 0;
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin[numItem];
                Assert.AreEqual(0, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn - 1, itemCourant.SellIn);
                numItem++;
            }
        }
Example #4
0
        public void TestUpdateQualityConjuredWithQualityTwiceAsFast()
        {
            //actor
            IList<Item> itemsOrigin = GetConjuredWithQualityTwiceAsFast();
            Inn inn = new Inn()
            {
                Items = GetConjuredWithQualityTwiceAsFast()
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            int numItem = 0;
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin[numItem];
                Assert.AreEqual(itemOrigin.Quality - 2, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn - 1, itemCourant.SellIn);
                numItem++;
            }
        }
Example #5
0
        public void TestUpdateQualitySulfurasLegendary()
        {
            //actor
            IList<Item> itemsOrigin = GetSulfuras();
            Inn inn = new Inn()
            {
                Items = GetSulfuras()
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            int numItem=0;
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin[numItem];
                Assert.AreEqual(itemOrigin.Quality, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn, itemCourant.SellIn);
                numItem++;
            }
        }
Example #6
0
        public void TestUpdateQualityOfAgedBrieImproveWhenOlder()
        {
            const int inputQuality = 0;
            //actor
            IList<Item> itemsOrigin = GetOneAgedBrieWithQuality(inputQuality);
            Inn inn = new Inn()
            {
                Items = GetOneAgedBrieWithQuality(inputQuality)
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin.First(it => itemCourant.Name.Equals(it.Name));
                Assert.AreEqual(itemOrigin.Quality + 1, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn - 1, itemCourant.SellIn);
            }
        }
Example #7
0
        public void TestUpdateQualityNeverNegative()
        {
            const int requiredQuality = 0;

            //actor
            IList<Item> itemsOrigin = GetFullListItemsWithinputQuality(requiredQuality);
            Inn inn = new Inn()
            {
                Items = GetFullListItemsWithinputQuality(requiredQuality)
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin.First(it => itemCourant.Name.Equals(it.Name));
                Assert.IsTrue(itemOrigin.Quality >= 0);
            }
        }
Example #8
0
        public void TestUpdateQualityIncreaseNeverMoreThan50()
        {
            const int requiredQuality = 50;

            //actor
            IList<Item> itemsOrigin = GetOneAgedBrieWithQuality(requiredQuality);
            Inn inn = new Inn()
            {
                Items = GetOneAgedBrieWithQuality(requiredQuality)
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin.First(it => itemCourant.Name.Equals(it.Name));
                Assert.AreEqual(requiredQuality, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn - 1, itemCourant.SellIn);
            }
        }
Example #9
0
        public void TestUpdateQualityDegradesTwiceAsFastWhenDatePassed()
        {
            //actor
            IList<Item> itemsOrigin = GetListItemsSellDatePassed();
            Inn inn = new Inn()
            {
                Items = GetListItemsSellDatePassed()
            };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin.First(it => itemCourant.Name.Equals(it.Name));
                Assert.AreEqual(itemOrigin.Quality - 2, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn - 1, itemCourant.SellIn);
            }
        }
Example #10
0
        public void TestUpdateQualityDecreaseSellinAndQualityValueOf1()
        {
            //actor
            IList<Item> itemsOrigin = GetListWithoutSpecialItems();
            Inn inn = new Inn()
                {
                    Items = GetListWithoutSpecialItems()
                };

            //action
            inn.UpdateQualityAndSellInAfterADay();

            //assert
            foreach (Item itemCourant in inn.Items)
            {
                Item itemOrigin = itemsOrigin.First(it => itemCourant.Name.Equals(it.Name));
                Assert.AreEqual(itemOrigin.Quality - 1, itemCourant.Quality);
                Assert.AreEqual(itemOrigin.SellIn - 1, itemCourant.SellIn);
            }
        }