示例#1
0
        Backstage_passes_like_aged_brie_by_2_when_there_are_10_days_or_less_and_by_3_when_there_are_5_days_or_less()
        {
            var          rose  = new BackstagePass(10, 20);
            IList <Rose> roses = new List <Rose> {
                rose
            };

            GildedRose gildedRose = new GildedRose(roses);

            for (var i = 0; i < 5; i++)
            {
                gildedRose.UpdateQuality();
            }

            var roseAfterFiveDays = new Rose("Backstage passes to a TAFKAL80ETC concert", 5, 31);

            Assert.True(roseAfterFiveDays.Equals(rose));

            for (var i = 0; i < 5; i++)
            {
                gildedRose.UpdateQuality();
            }

            var roseAfterTenDays = new Rose("Backstage passes to a TAFKAL80ETC concert", 0, 46);

            Assert.True(roseAfterTenDays.Equals(rose));
        }
示例#2
0
            public IGood BuildFor(Item item)
            {
                switch (item.Name)
                {
                case "Backstage passes to a TAFKAL80ETC concert":
                    return(BackstagePass.Build(item.SellIn));

                case "Aged Brie":
                    return(AgedBrie.Build(item.SellIn));

                case "Conjured Mana Cake":
                    return(Conjured.Build(item.SellIn));

                default:
                    return(Generic.Build(item.SellIn));
                }
            }
示例#3
0
        public void Backstage_passes_like_aged_brie_gets_quality_0_after_concert()
        {
            var          rose  = new BackstagePass(10, 20);
            IList <Rose> roses = new List <Rose> {
                rose
            };

            GildedRose gildedRose = new GildedRose(roses);

            for (var i = 0; i < 11; i++)
            {
                gildedRose.UpdateQuality();
            }

            var roseAfterElevenDays = new Rose("Backstage passes to a TAFKAL80ETC concert", -1, 0);

            Assert.True(roseAfterElevenDays.Equals(rose));
        }
示例#4
0
        private int NewQuality(Item item)
        {
            if (item.Name == "Sulfuras, Hand of Ragnaros")
            {
                return(item.Quality);
            }

            if (item.Name == "Aged Brie")
            {
                var brie = new Brie();
                return(brie.NewQuality(item));
            }

            if (item.Name == "Sulfuras")
            {
                var sulfuras = new Sulfuras();
                return(sulfuras.NewQuality(item));
            }

            if (item.Name == "Backstage passes to a TAFKAL80ETC concert")
            {
                var backstagePass = new BackstagePass();
                return(backstagePass.NewQuality(item));
            }

            if (item.Name.IndexOf("Conjured") == 0)
            {
                var conjured = new Conjured();
                return(conjured.NewQuality(item));
            }

            // other regular items
            var regular = new Regular();

            return(regular.NewQuality(item));
        }