public void Test_BackStageShouldSetQualityToZeroWhenSellInIsZero(int initialQuality, int expectedQuality, int sellIn)
 {
     IList<Item> Items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = initialQuality } };
     GildedRose app = new GildedRose(Items);
     app.UpdateQuality();
     Assert.AreEqual(expectedQuality, Items[0].Quality);
 }
示例#2
0
        public void Establish_SafeNet()
        {
            Goods[] items = new Goods[] {
                new Goods("+5 Dexterity Vest", 10, 20),    //
                new AgeBrie(2, 0),                         //
                new Goods("Elixir of the Mongoose", 5, 7), //
                new Goods("Elixir of the Mongoose", 1, 7), //
                new Sulfuras(0, 80),                       //
                new Sulfuras(-1, 80),
                new Tickets(15, 20),
                new Tickets(10, 49),
                new Tickets(5, 49),
                new Tickets(1, 20),
                // this conjured item does not work properly yet
                new Goods("Conjured Mana Cake", 3, 6)
            };

            GildedRose.GildedRose app     = new GildedRose.GildedRose(items);
            StringBuilder         builder = new StringBuilder();

            for (int i = 0; i < 3; i++)
            {
                app.update_quality();
                foreach (Goods item in items)
                {
                    builder.Append(item.ToString());
                }
            }

            var result =
                "+5 Dexterity Vest, 9, 19Aged Brie, 1, 1Elixir of the Mongoose, 4, 6Elixir of the Mongoose, 0, 6Sulfuras, Hand of Ragnaros, 0, 80Sulfuras, Hand of Ragnaros, -1, 80Backstage passes to a TAFKAL80ETC concert, 14, 21Backstage passes to a TAFKAL80ETC concert, 9, 50Backstage passes to a TAFKAL80ETC concert, 4, 50Backstage passes to a TAFKAL80ETC concert, 0, 23Conjured Mana Cake, 2, 5+5 Dexterity Vest, 8, 18Aged Brie, 0, 2Elixir of the Mongoose, 3, 5Elixir of the Mongoose, -1, 4Sulfuras, Hand of Ragnaros, 0, 80Sulfuras, Hand of Ragnaros, -1, 80Backstage passes to a TAFKAL80ETC concert, 13, 22Backstage passes to a TAFKAL80ETC concert, 8, 50Backstage passes to a TAFKAL80ETC concert, 3, 50Backstage passes to a TAFKAL80ETC concert, -1, 0Conjured Mana Cake, 1, 4+5 Dexterity Vest, 7, 17Aged Brie, -1, 4Elixir of the Mongoose, 2, 4Elixir of the Mongoose, -2, 2Sulfuras, Hand of Ragnaros, 0, 80Sulfuras, Hand of Ragnaros, -1, 80Backstage passes to a TAFKAL80ETC concert, 12, 23Backstage passes to a TAFKAL80ETC concert, 7, 50Backstage passes to a TAFKAL80ETC concert, 2, 50Backstage passes to a TAFKAL80ETC concert, -2, 0Conjured Mana Cake, 0, 3";

            Assert.AreEqual(result, builder.ToString());
        }
 public void foo()
 {
     IList<Item> Items = new List<Item> { new StandardItem(name: "PurestGreen", sellIn: 0, quality: 0) };
     GildedRose app = new GildedRose(Items);
     app.UpdateQuality();
     Assert.AreEqual("PurestGreen", Items[0].Name);
 }
 public void foo()
 {
     IList<Item> Items = new List<Item> { new Item{Name = "PurestGreen", SellIn = 0, Quality = 0} };
     GildedRose app = new GildedRose(Items);
     app.UpdateQuality();
     Assert.AreEqual("PurestGreen", Items[0].Name);
 }
示例#5
0
        public void SulfurasSellInAndQualityDoNotChange()
        {
            //given

            var itemList = 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
                }
            };

            //when
            var gildedRose = new GildedRose.GildedRose(itemList);

            //then

            gildedRose.UpdateQuality();

            itemList[0].Should().BeEquivalentTo(new Item {
                Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80
            });
            itemList[1].Should().BeEquivalentTo(new Item {
                Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80
            });
        }
 public void Test_ItemsQualityShouldDecreaseFaster_Negative(int actualS, int initialQ, int expectedQ)
 {
     IList<Item> Items = new List<Item> { new Item { Name = "foo", SellIn = actualS, Quality = initialQ } };
     GildedRose app = new GildedRose(Items);
     app.UpdateQuality();
     Assert.AreNotEqual(expectedQ, Items[0].Quality);
 }
示例#7
0
        public void ItemsDecreaseQualityByOneEachDayIfNotSpecial()
        {
            //given
            var item = new Item
            {
                Name    = "testItem",
                SellIn  = 5,
                Quality = 30
            };

            var itemList = new List <Item> {
                item
            };

            //when
            var gildedRose = new GildedRose.GildedRose(itemList);

            //then

            gildedRose.UpdateQuality();

            itemList[0].Should().BeEquivalentTo(new Item {
                Name = "testItem", SellIn = 4, Quality = 29
            });
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");

            var numberOfDays = 0;

            try
            {
                numberOfDays = int.Parse(args[0]);
            }
            catch (Exception)
            {
                numberOfDays = 31;
            }

            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 < numberOfDays; i++)
            {
                Console.WriteLine("-------- day " + i + " --------");
                Console.WriteLine("name, sellIn, quality");

                foreach (var item in items)
                {
                    Console.WriteLine(item.Name + ", " + item.SellIn + ", " + item.Quality);
                }

                Console.WriteLine();

                app.UpdateQuality();
            }
        }
示例#9
0
        public void BackstagePassesWithSellInBetweenFiveAndZeroAndQualityUnderFiftyIncreaseByThree()
        {
            //given

            var itemList = new List <Item>
            {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 5,
                    Quality = 3
                },
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 1,
                    Quality = 17
                },
            };

            //when
            var gildedRose = new GildedRose.GildedRose(itemList);

            //then

            gildedRose.UpdateQuality();

            itemList[0].Should().BeEquivalentTo(new Item {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 4, Quality = 6
            });
            itemList[1].Should().BeEquivalentTo(new Item {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 20
            });
        }
示例#10
0
        public void QualityOfAnItemIsNeverNegative()
        {
            var Items = new List <Item>
            {
                new Item {
                    Name = "Apple", SellIn = 10, Quality = 10
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 10, Quality = 10
                },
                new Item {
                    Name = "Apple", SellIn = 15, Quality = 13
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 15, Quality = 15
                }
            };

            var app = new GildedRose.GildedRose(Items);

            for (var i = 0; i < 100; i++)
            {
                app.UpdateQuality();
            }

            Assert.Equal(0, Items[0].Quality);
            Assert.Equal(0, Items[1].Quality);
            Assert.Equal(0, Items[2].Quality);
            Assert.Equal(0, Items[3].Quality);
        }
 public void Test_BackStageShouldIncreaseQualityByThreeWhenFiveOrLessDaysSellIn(int initialQuality, int expectedQuality, int sellIn)
 {
     IList<Item> Items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = initialQuality } };
     GildedRose app = new GildedRose(Items);
     app.UpdateQuality();
     Assert.AreEqual(expectedQuality, Items[0].Quality);
 }
示例#12
0
 public void Test2()
 {
     IList<Item> items = new List<Item> { new Item{Name = "My user", SellIn = 0, Quality = 0} };
     GildedRose app = new GildedRose(items);
     app.UpdateQuality();
     Assert.GreaterOrEqual(items[0].Quality, 0);
 }
示例#13
0
        public void SpecialItemsExceptSulfurasMaxQualityIsFifty()
        {
            //given

            var itemList = new List <Item>
            {
                new Item
                {
                    Name    = "Aged Brie",
                    SellIn  = 1,
                    Quality = 50
                },
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 8,
                    Quality = 50
                },
            };

            //when
            var gildedRose = new GildedRose.GildedRose(itemList);

            //then

            gildedRose.UpdateQuality();

            itemList[0].Should().BeEquivalentTo(new Item {
                Name = "Aged Brie", SellIn = 0, Quality = 50
            });
            itemList[1].Should().BeEquivalentTo(new Item {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 7, Quality = 50
            });
        }
示例#14
0
        public void BackStagePassIncreaseByOneIfMoreThanTenDaysLeft()
        {
            //given
            var pass = new Item
            {
                Name    = "Backstage passes to a TAFKAL80ETC concert",
                SellIn  = 15,
                Quality = 20
            };

            var itemList = new List <Item> {
                pass
            };

            //when
            var gildedRose = new GildedRose.GildedRose(itemList);

            //then

            gildedRose.UpdateQuality();

            itemList[0].Should().BeEquivalentTo(new Item {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 14, Quality = 21
            });
        }
示例#15
0
        public void SpecialItemsExceptSulfurasWithQualityLessThanFiftyIncreaseQualityEachDay()
        {
            //given

            var itemList = new List <Item>
            {
                new Item
                {
                    Name    = "Aged Brie",
                    SellIn  = 1,
                    Quality = 39
                },
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 20,
                    Quality = 24
                },
            };

            //when
            var gildedRose = new GildedRose.GildedRose(itemList);

            //then

            gildedRose.UpdateQuality();

            itemList[0].Should().BeEquivalentTo(new Item {
                Name = "Aged Brie", SellIn = 0, Quality = 40
            });
            itemList[1].Should().BeEquivalentTo(new Item {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 19, Quality = 25
            });
        }
        public static void Main(string[] args)
        {
            System.Console.WriteLine("Gilded Rose Stuff!");

            IList<Item> Items = new List<Item>{
                new StandardItem (name: "+5 Dexterity Vest",                           sellIn: 10,    quality: 20),
                new AgedBrie (sellIn: 2,     quality: 0 ),
                new StandardItem (name: "Elixir of the Mongoose",                      sellIn: 5,     quality: 7 ),
                new Sulfurus (quality: 80),
                new Sulfurus (quality: 80),
                new BackstagePass (artist: "TAFKAL80ETC",   sellIn: 15,    quality: 20),
                new BackstagePass (artist: "TAFKAL80ETC",   sellIn: 10,    quality: 49),
                new BackstagePass (artist: "TAFKAL80ETC",   sellIn: 5,     quality: 49),
                new ConjuredItem (name: "Conjured Mana Cake",                          sellIn: 3,     quality: 6 )// this conjured item does not work properly yet
            };

            var app = new GildedRose(Items);

            for (var i = 0; i < 31; i++)
            {
                System.Console.WriteLine("-------- day " + i + " --------");
                System.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);
                }
                System.Console.WriteLine("");
                app.UpdateQuality();
            }
        }
示例#17
0
        public void BackstagePassesWithSellInBelowZeroDropQualityToZero()
        {
            //given

            var itemList = new List <Item>
            {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 0,
                    Quality = 3
                }
            };

            //when
            var gildedRose = new GildedRose.GildedRose(itemList);

            //then

            gildedRose.UpdateQuality();

            itemList[0].Should().BeEquivalentTo(new Item {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -1, Quality = 0
            });
        }
示例#18
0
 public void Test3()
 {
     IList<Item> items = new List<Item> { new Item { Name = "Aged Brie", SellIn = 7, Quality = 6 } };
     GildedRose app = new GildedRose(items);
     var fQuality = items[0].Quality;
     app.UpdateQuality();
     Assert.Greater(items[0].Quality, fQuality);
 }
示例#19
0
        public void shouldCheckDefaultOutput()
        {
            List <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
                }
            };

            var app = new GildedRose.GildedRose(Items);

            app.UpdateQuality();

            List <Item> expectedOutput = new List <Item>()
            {
                new Item {
                    Name = "+5 Dexterity Vest", SellIn = 9, Quality = 19
                },
                new Item {
                    Name = "Aged Brie", SellIn = 1, Quality = 1
                },
                new Item {
                    Name = "Elixir of the Mongoose", SellIn = 4, Quality = 6
                },
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 14, Quality = 21
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 2, Quality = 5
                }
            };


            expectedOutput[0].Should().BeEquivalentTo(Items[0]);
            expectedOutput[1].Should().BeEquivalentTo(Items[1]);
            expectedOutput[2].Should().BeEquivalentTo(Items[2]);
            expectedOutput[3].Should().BeEquivalentTo(Items[3]);
            expectedOutput[4].Should().BeEquivalentTo(Items[4]);
            expectedOutput[5].Should().BeEquivalentTo(Items[5]);
        }
示例#20
0
 public void Test4()
 {
     // Quality can increase only in special ways (Name = "Aged Brie" "Backstage passes to a TAFKAL80ETC concert")
     // Name ="Sulfuras" quality=80 (more than 50)
     IList<Item> items = new List<Item> { new Item { Name = "Aged Brie", SellIn = 11, Quality = 50 } };
     GildedRose app = new GildedRose(items);
     app.UpdateQuality();
     Assert.Greater(51, items[0].Quality);
 }
示例#21
0
        protected static void UpdateItem(Item item)
        {
            GildedRose.GildedRose rose = new GildedRose.GildedRose(new List <Item>()
            {
                item
            });

            rose.UpdateQuality();
        }
示例#22
0
        public void TestUpdateQuality()
        {
            IList <Item> Items = new List <Item>();

            Items.Add(new Item {
                Name = "foo", SellIn = 5, Quality = 3
            });
            Items.Add(new Item {
                Name = "foo1", SellIn = 7, Quality = 4
            });
            Items.Add(new Item {
                Name = "foo2", SellIn = 6, Quality = 5
            });
            Items.Add(new Item {
                Name = "Aged Brie", SellIn = 10, Quality = 20
            });
            Items.Add(new Item {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 50, Quality = 10
            });
            Items.Add(new Item {
                Name = "Sulfuras, Hand of Ragnaros", SellIn = 5, Quality = 20
            });

            GildedRose.GildedRose app = new GildedRose.GildedRose(Items);

            //1.- First day update
            app.UpdateQuality();

            //foo - Then
            Assert.AreEqual(4, Items[0].SellIn);
            Assert.AreEqual(2, Items[0].Quality);

            //Aged Brie - Then
            Assert.AreEqual(9, Items[3].SellIn);
            Assert.AreEqual(21, Items[3].Quality);

            //Backstage passes - Then
            Assert.AreEqual(49, Items[4].SellIn);
            Assert.AreEqual(11, Items[4].Quality);


            //2.- Second day update
            app.UpdateQuality();

            //foo - Then
            Assert.AreEqual(3, Items[0].SellIn);
            Assert.AreEqual(1, Items[0].Quality);

            //Aged Brie - Then
            Assert.AreEqual(8, Items[3].SellIn);
            Assert.AreEqual(22, Items[3].Quality);

            //Backstage passes - Then
            Assert.AreEqual(48, Items[4].SellIn);
            Assert.AreEqual(12, Items[4].Quality);
        }
        public void BackstagePassShouldLoseQualityOnSellInDate()
        {
            IList<Item> items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 5 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -1, Quality = 0 };
            expected.ShouldBeEquivalentTo(items[0]);
        }
        public void BackstagePassShouldIncreaseInQualityTwiceAsFastWhenConcertIsApproaching()
        {
            IList<Item> items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 10, Quality = 5 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 9, Quality = 7 };
            expected.ShouldBeEquivalentTo(items[0]);
        }
        public void AgedBrieShouldIncreaseInQualityTwiceAsFastAfterSellInDate()
        {
            IList<Item> items = new List<Item> { new Item { Name = "Aged Brie", SellIn = 0, Quality = 5 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "Aged Brie", SellIn = -1, Quality = 7 };
            expected.ShouldBeEquivalentTo(items[0]);
        }
示例#26
0
 public void Test5()
 {
     IList<Item> items = new List<Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 11, Quality = 6 } };
     GildedRose app = new GildedRose(items);
     var fSellIn = items[0].SellIn;
     var fQuality = items[0].Quality;
     app.UpdateQuality();
     Assert.AreEqual(items[0].SellIn, fSellIn);
     Assert.GreaterOrEqual(items[0].Quality, fQuality);
 }
示例#27
0
        public void foo()
        {
            Goods[] items = new Goods[] { new Goods("foo", 1, 5) };
            var     app   = new GildedRose.GildedRose(items);

            app.update_quality();
            Assert.AreEqual("foo", app.items[0].Name);
            Assert.AreEqual(app.items[0].Quality, (4));
            Assert.AreEqual(app.items[0].SellIn, (0));
        }
        public void Test_Baja_SellIn()
        {
            const int actualSellin = 5;
            const int expectedSellin = 4;

            IList<Item> Items = new List<Item> { new Item { Name = "foo", SellIn = actualSellin, Quality = 5 } };
            GildedRose app = new GildedRose(Items);
            app.UpdateQuality();
            Assert.AreEqual(expectedSellin, Items[0].SellIn);
        }
示例#29
0
        public void QualityDecreasesForRegularItems()
        {
            var item = new Item {
                Name = "Test Item", Quality = 10, SellIn = 5
            };
            var gildedRose = new GildedRose.GildedRose(new List <Item> {
                item
            });

            gildedRose.UpdateQuality();
            item.Quality.Should().Be(9);
        }
示例#30
0
        public void Foo()
        {
            IList <Item> items = new List <Item> {
                new Item {
                    Name = "foo", SellIn = 0, Quality = 0
                }
            };

            GildedRose.GildedRose app = new GildedRose.GildedRose(items);
            app.UpdateQuality();
            Assert.Equal("fixme", items[0].Name);
        }
示例#31
0
        public void ConjuredItemsDegradeTwiceAsFast()
        {
            var item = new Item {
                Name = "Conjured Mana Cake", Quality = 10, SellIn = 5
            };
            var gildedRose = new GildedRose.GildedRose(new List <Item> {
                item
            });

            gildedRose.UpdateQuality();
            item.Quality.Should().Be(8);
        }
示例#32
0
        public void SulfurasSellDateNeverDecreases()
        {
            var item = new Item {
                Name = "Sulfuras, Hand of Ragnaros", Quality = 10, SellIn = 5
            };

            var gildedRose = new GildedRose.GildedRose(new List <Item> {
                item
            });

            gildedRose.UpdateQuality();
            item.SellIn.Should().Be(5);
        }
示例#33
0
        public void QualityNeverMoreThan50()
        {
            var item = new Item {
                Name = "Aged Brie", Quality = 50, SellIn = 5
            };

            var gildedRose = new GildedRose.GildedRose(new List <Item> {
                item
            });

            gildedRose.UpdateQuality();
            item.Quality.Should().Be(50);
        }
示例#34
0
        public void ItemNameDoesNotChange()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Aged Brie", SellIn = 10, Quality = 10
                }
            };

            GildedRose.GildedRose app = new GildedRose.GildedRose(Items);
            app.UpdateQuality();

            Assert.Equal("Aged Brie", Items[0].Name);
        }
示例#35
0
        public void SellInDecreasesBy1EachDayForRegularItems()
        {
            var Items = new List <Item>
            {
                new Item {
                    Name = "Test Item", SellIn = 5, Quality = 10
                }
            };

            _gildedRose = new GildedRose.GildedRose(Items);
            _gildedRose.UpdateQuality();
            Items[0].SellIn.Should().Be(4);
        }
示例#36
0
        public void AgedBrieIncreasesInQuality()
        {
            var item = new Item {
                Name = "Aged Brie", Quality = 11, SellIn = 5
            };

            _gildedRose = new GildedRose.GildedRose(new List <Item> {
                item
            });
            _gildedRose.UpdateQuality();

            item.Quality.Should().Be(12);
        }
示例#37
0
        public void SulfurasNeverSoldOrLowersInQuality()
        {
            var Items = new List <Item> {
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 10, Quality = 80
                }
            };
            var app = new GildedRose.GildedRose(Items);

            app.UpdateQuality();

            Assert.Equal(10, Items[0].SellIn);
            Assert.Equal(80, Items[0].Quality);
        }
示例#38
0
        public void TestItem()
        {
            //Given
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "item1", SellIn = 0, Quality = 0
                }
            };

            //When
            GildedRose.GildedRose app = new GildedRose.GildedRose(Items);
            //Then
            Assert.AreEqual("item1", Items[0].Name);
        }
示例#39
0
        public static void Main(string[] args)
        {
            System.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}
			};

            GildedRose app = new GildedRose(items);

            for (int i = 0; i < 31; i++)
            {
                System.Console.WriteLine("-------- day " + i + " --------");
                System.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);
                }
                System.Console.WriteLine("");
                app.UpdateQuality();
            }

            System.Console.ReadLine();
        }
示例#40
0
        public void Test1(int a, int b,int c)
        {
            IList<Item> items = new List<Item> { new Item { Name = "My user", SellIn = a, Quality = 6 } };
            GildedRose app = new GildedRose(items);
            var fQuality = items[0].Quality;
            app.UpdateQuality();
            var deltaQ = items[0].Quality - fQuality;

            IList<Item> items1 = new List<Item> { new Item { Name = "My user", SellIn = b, Quality = 6 } };
            GildedRose app2 = new GildedRose(items1);
            var fQuality2 = items1[0].Quality;
            app2.UpdateQuality();
            var deltaQ2 = items1[0].Quality - fQuality2;

            Assert.AreEqual(deltaQ*c, deltaQ2);
        }
示例#41
0
        public void test_Backstage_passes_to_a_TAFKAL80ETC_concert_with_positive_quantity_and_negative_sellin(int sellIn, int quality)
        {
            IList <Item> roses = new List <Item>
            {
                new Item
                {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = quality
                }
            };

            var app = new GildedRose.GildedRose(roses);

            app.UpdateQuality();

            Assert.Equal(0, roses[0].Quality);
        }
示例#42
0
        public void QualityOfAnItemIsNeverGreaterThan50()
        {
            var Items = new List <Item> {
                new Item {
                    Name = "Aged Brie", SellIn = 50, Quality = 10
                }
            };
            var app = new GildedRose.GildedRose(Items);

            for (var i = 0; i < 100; i++)
            {
                app.UpdateQuality();
            }

            Assert.Equal(50, Items[0].Quality);
        }
示例#43
0
        public void test_sellin_less_then_6(int sellIn, int quality)
        {
            IList <Item> roses = new List <Item>
            {
                new Item
                {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = sellIn, Quality = quality
                }
            };

            var app = new GildedRose.GildedRose(roses);

            app.UpdateQuality();

            Assert.Equal(quality + 3, roses[0].Quality);
        }
示例#44
0
        public void BackstagePassQualityDoesntGoOver50()
        {
            var Items = new List <Item> {
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 30, Quality = 10
                }
            };
            var app = new GildedRose.GildedRose(Items);

            for (var i = 0; i < 30; i++)
            {
                app.UpdateQuality();
            }

            Assert.Equal(50, Items[0].Quality);
        }
示例#45
0
        public void BackstagePassesStillHaveQualityAtDayOf()
        {
            var Items = new List <Item> {
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 20, Quality = 10
                }
            };
            var app = new GildedRose.GildedRose(Items);

            for (var i = 0; i < 20; i++)
            {
                app.UpdateQuality();
            }

            Assert.Equal(45, Items[0].Quality);
        }
示例#46
0
        public void BackstagePassesDropTo0AfterSellByDatePasses()
        {
            var Items = new List <Item> {
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 20, Quality = 10
                }
            };
            var app = new GildedRose.GildedRose(Items);

            for (var i = 0; i < 21; i++)
            {
                app.UpdateQuality();
            }

            Assert.Equal(0, Items[0].Quality);
        }
示例#47
0
        public void test_rose_with_positive_quality_and_negative_sellin(int sellIn, int quality)
        {
            IList <Item> roses = new List <Item>
            {
                new Item
                {
                    Name = "Rose", SellIn = sellIn, Quality = quality
                }
            };

            var app = new GildedRose.GildedRose(roses);

            app.UpdateQuality();

            Assert.Equal(quality - 2, roses[0].Quality);
        }
        public static void Main(string[] args)
        {
            var 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
                }
            };

            var app = new GildedRose(items);

            for (var i = 0; i < 31; i++)
            {
                Console.WriteLine("-------- day " + i + " --------");
                Console.WriteLine("name, sellIn, quality");
                foreach (Item item in items)
                {
                    Console.WriteLine(item.Name + ", " + item.SellIn + ", " + item.Quality);
                }
                Console.WriteLine("");
                app.UpdateQuality();
            }
        }
        public static void Main(string[] args)
        {
            System.Console.WriteLine("OMGHAI!");

            IList<UpdatableItem> Items = new List<UpdatableItem>{
                new UpdatableItem {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                new AgedBrie {SellIn = 2, Quality = 0},
                new UpdatableItem {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                new Sulfuras {SellIn = 0, Quality = 80},
                new Sulfuras {SellIn = -1, Quality = 80},
                new BackstagePass
                {
                    SellIn = 15,
                    Quality = 20
                },
                new BackstagePass
                {
                    SellIn = 10,
                    Quality = 49
                },
                new BackstagePass
                {
                    SellIn = 5,
                    Quality = 49
                },
                new ConjuredItem {Name = "Conjured Mana Cake", SellIn = 3, Quality = 16}
            };

            var app = new GildedRose(Items);

            for (var i = 0; i < 31; i++) {
                System.Console.WriteLine("-------- day " + i + " --------");
                System.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);
                }
                System.Console.WriteLine("");
                app.UpdateQuality();
            }
        }
        public void ItemShouldNotIncreaseInQualityAbove50()
        {
            IList<Item> items = new List<Item> { new Item { Name = "Aged Brie", SellIn = 10, Quality = 50 }, new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 20, Quality = 50 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var brie = new Item { Name = "Aged Brie", SellIn = 9, Quality = 50 };
            brie.ShouldBeEquivalentTo(items[0]);

            var concert = new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 19, Quality = 50 };
            concert.ShouldBeEquivalentTo(items[1]);
        }
 public static void Main(String[] args)
 {
     var gildedRose = new GildedRose();
     gildedRose.UpdateQuality(gildedRose.MakeItems());
 }
示例#52
0
 public void Test6_1()
 {
     IList<Item> items3 = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 6 } };
     GildedRose app3 = new GildedRose(items3);
     app3.UpdateQuality();
     Assert.AreEqual(0, items3[0].Quality);
 }
示例#53
0
        public void Test7()
        {
            // My user is normal Item
            IList<Item> items = new List<Item> { new Item { Name = "My user", SellIn = 3, Quality = 6 } };
            GildedRose app = new GildedRose(items);
            var fQuality = items[0].Quality;
            app.UpdateQuality();
            var deltaQ = items[0].Quality - fQuality;

            IList<Item> items2 = new List<Item> { new Item { Name = "Conjured", SellIn = 3, Quality = 6 } };
            GildedRose app2 = new GildedRose(items2);
            var fQuality2 = items2[0].Quality;
            app2.UpdateQuality();
            var deltaQ2 = items2[0].Quality - fQuality2;
            Assert.AreEqual(deltaQ * 2, deltaQ2);
        }
示例#54
0
        public void Test6(int a, int b)
        {
            IList<Item> items1 = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = a, Quality = 6 } };
            GildedRose app1 = new GildedRose(items1);
            var fQuality1 = items1[0].Quality;
            app1.UpdateQuality();
            var deltaQ1 = items1[0].Quality - fQuality1;
            Assert.AreEqual(b, deltaQ1);

            //IList<Item> items2 = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = a, Quality = 6 } };
            //GildedRose app2 = new GildedRose(items2);
            //var fQuality2 = items2[0].Quality;
            //app2.UpdateQuality();
            //var deltaQ2 = items2[0].Quality - fQuality2;
            //Assert.AreEqual(b, deltaQ2);

            //IList<Item> items3 = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 6 } };
            //GildedRose app3 = new GildedRose(items3);
            //app3.UpdateQuality();
            //Assert.AreEqual(0, items3[0].Quality);
        }
        public void ConjuredItemsShouldLoseQualityTwiceAsFast()
        {
            IList<Item> items = new List<Item> { new Item { Name = "Conjured foo", SellIn = 10, Quality = 5 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "Conjured foo", SellIn = 9, Quality = 3 };
            expected.ShouldBeEquivalentTo(items[0]);
        }
        public void ItemShouldDegradeInQualityTwiceAsFastAfterTheSellInDate()
        {
            IList<Item> items = new List<Item> { new Item { Name = "foo", SellIn = 0, Quality = 5 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "foo", SellIn = -1, Quality = 3 };
            expected.ShouldBeEquivalentTo(items[0]);
        }
        public void ItemShouldNeverDegradeBelowZero()
        {
            IList<Item> items = new List<Item> { new Item { Name = "foo", SellIn = 0, Quality = 0 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "foo", SellIn = -1, Quality = 0 };
            expected.ShouldBeEquivalentTo(items[0]);
        }
示例#58
0
 public void Test8(int a)
 {
     IList<Item> items = new List<Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 11, Quality = a } };
     GildedRose app = new GildedRose(items);
     app.UpdateQuality();
     Assert.AreEqual(items[0].Quality, 80);
 }
        public void ItemShouldDegradeInQuality()
        {
            IList<Item> items = new List<Item> { new Item { Name = "foo", SellIn = 10, Quality = 5 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "foo", SellIn = 9, Quality = 4 };
            expected.ShouldBeEquivalentTo(items[0]);
        }
        public void SulfurasShouldNotChangeQuality()
        {
            IList<Item> items = new List<Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 10, Quality = 80 } };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();

            var expected = new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 10, Quality = 80 };
            expected.ShouldBeEquivalentTo(items[0]);
        }