예제 #1
0
        public void UpdateQuality_Should_Be_Faster_When_SellInExpired()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "foo", SellIn = 0, Quality = 10
                },
                new Item {
                    Name = "Aged Brie", SellIn = 0, Quality = 2
                },
                new Item {
                    Name = "Aged Brie", SellIn = -1, Quality = 2
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Items[0].Quality.Should().Be(8);
            Items[1].Quality.Should().Be(4);
            Items[2].Quality.Should().Be(4);
        }
예제 #2
0
        public void Foo()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "BackStage passes Metallica", SellIn = 3, Quality = 10
                },
                new Item {
                    Name = "conjured backstage Apple", SellIn = 2, Quality = 50
                }
            };

            for (int i = 0; i < 3; i++)
            {
                GildedRose app = new GildedRose(Items);
                app.UpdateQuality();
            }

            Assert.Equal(19, Items[0].Quality);
            Assert.Equal(42, Items[1].Quality);
        }
예제 #3
0
        public void UpdateQuality_Should_UpdateQualityAndSellIn()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "foo", SellIn = 10, Quality = 10
                },
                new Item {
                    Name = "foo", SellIn = 1, Quality = 10
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Items[0].Quality.Should().Be(9);
            Items[0].SellIn.Should().Be(9);

            Items[1].Quality.Should().Be(9);
            Items[1].SellIn.Should().Be(0);
        }
예제 #4
0
        public void SellInRemainsConstant_QualityAlwaysEquals80_ForSulfuras()
        {
            IList <Item> Items = new List <Item>
            {
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80
                },
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.Equal("Sulfuras, Hand of Ragnaros", Items[0].Name);
            Assert.Equal(0, Items[0].SellIn);
            Assert.Equal(80, Items[0].Quality);
            Assert.Equal("Sulfuras, Hand of Ragnaros", Items[1].Name);
            Assert.Equal(-1, Items[1].SellIn);
            Assert.Equal(80, Items[1].Quality);
        }
예제 #5
0
        public void Quality_Should_IncreaseBy3_When_SellIn_LessOrEqualThan5()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 10
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 4, Quality = 10
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 1, Quality = 10
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Items[0].Quality.Should().Be(13);
            Items[1].Quality.Should().Be(13);
            Items[2].Quality.Should().Be(13);
        }
예제 #6
0
        public void UpdateQuality_Given_Sell_By_Date_Has_Not_Passed_Quality_Should_Decrease_In_One()
        {
            var items = new List <Item>()
            {
                new Item("foo")
                {
                    SellIn = 10, Quality = 10
                },
                new Item("bar")
                {
                    SellIn = 5, Quality = 10
                }
            };

            var app = new GildedRose(items);

            app.UpdateItem();

            Assert.Equal(9, items[0].Quality);
            Assert.Equal(9, items[1].Quality);
        }
예제 #7
0
        public void UpdateQuality_Given_Sell_By_Date_Has_Passed_Quality_Should_Decrease_Twice_As_Fast()
        {
            var items = new List <Item>()
            {
                new Item("foo")
                {
                    SellIn = -5, Quality = 10
                },
                new Item("bar")
                {
                    SellIn = -1, Quality = 15
                }
            };

            var app = new GildedRose(items);

            app.UpdateItem();

            Assert.Equal(8, items[0].Quality);
            Assert.Equal(13, items[1].Quality);
        }
예제 #8
0
        public void foo()
        {
            IList <Item> 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    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 15,
                    Quality = 20
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 3, Quality = 6
                }
            };
            GildedRose app = new GildedRose(Items);

            //First day
            app.UpdateQuality();
            Assert.Equal("+5 Dexterity Vest", Items[0].Name);
            Assert.Equal(9, Items[0].SellIn);
            Assert.Equal(19, Items[0].Quality);

            //Second day
            app.UpdateQuality();
            Assert.Equal("+5 Dexterity Vest", Items[0].Name);
            Assert.Equal(8, Items[0].SellIn);
            Assert.Equal(18, Items[0].Quality);
        }
예제 #9
0
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");
            ItemsInit    initItems = new ItemsInit();
            IList <Item> Items     = initItems.Init();

            //Unit tests
            var test = new GildedRoseTest();

            test.foo();

            // Printing results form Switch and GildedRose
            var app  = new Switch(Items);
            var app1 = new GildedRose(Items);

            //Switch
            System.Console.WriteLine("Printing new Switch");
            printResults(app, Items);
            //GildedRose
            System.Console.WriteLine("Printing default GildedRose");
            printResults(app1, Items);
        }
예제 #10
0
        public void TestQualityNeverGreaterMaxQuality()
        {
            var items = new List <(IItem item, DateTime dateCreated)>
            {
                (item : new DegradingItem
                {
                    Name = "+5 Dexterity Vest",
                    SellIn = 0,
                    Quality = 0
                }, dateCreated : DateTime.Today),
                (item : new AgedItem
                {
                    Name = "Aged Brie",
                    SellIn = 0,
                    Quality = 0
                }, dateCreated : DateTime.Today),
                (item : new ConcertTicket
                {
                    Name = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn = 0,
                    Quality = 0
                }, dateCreated : DateTime.Today),
                (item : new ConjuredItem
                {
                    Name = "Conjured Mana Cake",
                    SellIn = 0,
                    Quality = 0
                }, dateCreated : DateTime.Today)
            };

            var result = GildedRose.UpdateQuality(DateTime.Today.AddDays(1), items).ToList();

            Assert.True(result[0].Quality <= 50);
            Assert.True(result[1].Quality <= 50);
            Assert.True(result[2].Quality <= 50);
            Assert.True(result[3].Quality <= 50);
        }
예제 #11
0
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");

            IList <Item> 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
                }
            };

            var app = new GildedRose(Items);


            for (var i = 0; i < 31; i++)
            {
                Console.WriteLine("-------- day " + i + " --------");
                Console.WriteLine("name, sellIn, quality");
                for (var j = 0; j < Items.Count; j++)
                {
                    System.Console.WriteLine(Items[j].Name + ", " + Items[j].SellIn + ", " + Items[j].Quality);
                }
                Console.WriteLine("");
                app.UpdateQuality();
            }
            if (Debugger.IsAttached)
            {
                Console.WriteLine("Press any key to continue . . .");
                Console.ReadLine();
            }
        }
예제 #12
0
        private void CreateAppAndUpdateQuality(IList <Item> items)
        {
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!\n");

            IList <Item> 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
                },
                new Item
                {
                    Name    = "Conjured Mana Cake",
                    SellIn  = 3,
                    Quality = 6
                }
            };

            var app = new GildedRose(Items);

            for (var i = 0; i < 31; i++)
            {
                Console.WriteLine("-------- day " + i + " --------");
                Console.WriteLine("name, sellIn, quality");
                for (var j = 0; j < Items.Count; j++)
                {
                    Console.WriteLine(Items[j].Name + ", " + Items[j].SellIn + ", " + Items[j].Quality);
                }
                Console.WriteLine("");
                app.UpdateQuality();
            }
        }