示例#1
0
        public void GivenConjuredItem_WhenOneDayPassesAndSellInDateBelowZero_ItemQualityDecreasedByFourAndSellInDateDecreased()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Conjured Item",
                    SellIn  = 0,
                    Quality = 20
                }
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            var expectedItem = new Item
            {
                Name    = "Conjured Item",
                SellIn  = -1,
                Quality = 16
            };

            var actualItem = app.GetItems().First();

            Assert.AreEqual(expectedItem.SellIn, actualItem.SellIn);
            Assert.AreEqual(expectedItem.Name, actualItem.Name);
            Assert.AreEqual(expectedItem.Quality, actualItem.Quality);
        }
示例#2
0
        public void GivenConjuredItemWithQualityOfZero_WhenOneDayPassesAndSellInAboveZero_ItemQualityNotChangedAndSellInDateDecreased()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Conjured Item",
                    SellIn  = 1,
                    Quality = 0
                }
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            var expectedItem = new Item
            {
                Name    = "Conjured Item",
                SellIn  = 0,
                Quality = 0
            };

            var actualItem = app.GetItems().First();

            Assert.AreEqual(expectedItem.SellIn, actualItem.SellIn);
            Assert.AreEqual(expectedItem.Name, actualItem.Name);
            Assert.AreEqual(expectedItem.Quality, actualItem.Quality);
        }
示例#3
0
        public void GivenAgedBrieWithQualityOfFifty_WhenOneDayPassesAndSellInDateBelowZero_ItemQualityNotIncreasedAndSellInDateDecreased()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Aged Brie",
                    SellIn  = 0,
                    Quality = 50
                }
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            var expectedItem = new Item
            {
                Name    = "Aged Brie",
                SellIn  = -1,
                Quality = 50
            };

            var actualItem = app.GetItems().First();

            Assert.AreEqual(expectedItem.SellIn, actualItem.SellIn);
            Assert.AreEqual(expectedItem.Name, actualItem.Name);
            Assert.AreEqual(expectedItem.Quality, actualItem.Quality);
        }
示例#4
0
        public void GivenBackStagePassWithQualityOfFifty_WhenOneDayPassesAndSellInAboveFiveAndBelowTen_ItemQualityNotIncreasedAndSellInDateDecreased()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 6,
                    Quality = 50
                }
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            var expectedItem = new Item
            {
                Name    = "Backstage passes to a TAFKAL80ETC concert",
                SellIn  = 5,
                Quality = 50
            };

            var actualItem = app.GetItems().First();

            Assert.AreEqual(expectedItem.SellIn, actualItem.SellIn);
            Assert.AreEqual(expectedItem.Name, actualItem.Name);
            Assert.AreEqual(expectedItem.Quality, actualItem.Quality);
        }
示例#5
0
        public void GivenAgedBrie_WhenOneDayPassesAndSellInDateAboveZero_ItemQualityIncreasedByOneAndSellInDateDecreased()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Aged Brie",
                    SellIn  = 10,
                    Quality = 20
                }
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            var expectedItem = new Item
            {
                Name    = "Aged Brie",
                SellIn  = 9,
                Quality = 21
            };

            var actualItem = app.GetItems().First();

            Assert.AreEqual(expectedItem.SellIn, actualItem.SellIn);
            Assert.AreEqual(expectedItem.Name, actualItem.Name);
            Assert.AreEqual(expectedItem.Quality, actualItem.Quality);
        }
示例#6
0
        public void GivenBackStagePass_WhenOneDayPassesAndSellInAboveZeroAndBelowFive_ItemQualityIncreasedByThreeAndSellInDateDecreased()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 1,
                    Quality = 20
                }
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            var expectedItem = new Item
            {
                Name    = "Backstage passes to a TAFKAL80ETC concert",
                SellIn  = 0,
                Quality = 23
            };

            var actualItem = app.GetItems().First();

            Assert.AreEqual(expectedItem.SellIn, actualItem.SellIn);
            Assert.AreEqual(expectedItem.Name, actualItem.Name);
            Assert.AreEqual(expectedItem.Quality, actualItem.Quality);
        }
示例#7
0
        public void GivenSulfuras_WhenOneDayPasses_NothingChangedInTheItem()
        {
            var items = new List <Item>
            {
                new Item
                {
                    Name    = "Sulfuras, Hand of Ragnaros",
                    SellIn  = 10,
                    Quality = 80
                }
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            var expectedItem = new Item
            {
                Name    = "Sulfuras, Hand of Ragnaros",
                SellIn  = 10,
                Quality = 80
            };

            var actualItem = app.GetItems().First();

            Assert.AreEqual(expectedItem.SellIn, actualItem.SellIn);
            Assert.AreEqual(expectedItem.Name, actualItem.Name);
            Assert.AreEqual(expectedItem.Quality, actualItem.Quality);
        }
示例#8
0
        public void SetUp()
        {
            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    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 15,
                    Quality = 20
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 3, Quality = 6
                },
                new Item {
                    Name = "Spoiled Item", Quality = 10, SellIn = 0
                },
                new Item {
                    Name = "Low Quality Item", Quality = 1, SellIn = 1
                },
                new Item {
                    Name = "Conjured Mana Cake", Quality = 5, SellIn = 5
                },
                new Item {
                    Name = "Conjured Water", Quality = 7, SellIn = 7
                }
            };

            _app   = new GildedRose(items);
            _items = _app.GetItems();
        }
示例#9
0
 private void UpdateQuality()
 {
     _app.UpdateQuality();
     _items = _app.GetItems();
 }
示例#10
0
        public static void Main(string[] args)
        {
            LoadConfiguration();
            InjectDependencies();
            LoadItemsType();

            Console.WriteLine("OMGHAI!");

            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 = "Aged Brie", SellIn = -1, Quality = 0
                },
                new Item {
                    Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7
                },
                new Item {
                    Name = "Elixir of the Mongoose", SellIn = -1, Quality = 2
                },
                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 = "Backstage passes to a TAFKAL80ETC concert", SellIn = -2, Quality = 2
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 5, Quality = 10
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = -1, Quality = 6
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 2, Quality = 6
                }
            };

            var gildedRoseCore = new GildedRose(_itemFactory);

            gildedRoseCore.SetItems(items);

            for (var i = 0; i < 31; i++)
            {
                Console.WriteLine("-------- day " + i + " --------");
                Console.WriteLine("name, sellIn, quality");

                var coreItems = gildedRoseCore.GetItems();

                for (var j = 0; j < items.Count; j++)
                {
                    Console.WriteLine(coreItems[j].Name + ", " + coreItems[j].SellIn + ", " + coreItems[j].Quality);
                }
                Console.WriteLine("");

                gildedRoseCore.UpdateQuality();
            }
        }
        public void AlvaroCharacterizationTest()
        {
            // Prepare
            List <Item> initialItems = new List <Item>
            {
                // Kata example
                new Item {
                    Name = "Alvaro's Test", SellIn = 5, Quality = 49
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = -2, Quality = 2
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 12, Quality = 50
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 11, Quality = 10
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 6, Quality = 10
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 5, Quality = 1
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 0, Quality = 50
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = -3, Quality = 0
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 5, Quality = 0
                }
            };

            var expectedResult = new List <Item>
            {
                new Item {
                    Name = "Alvaro's Test", SellIn = 5, Quality = 48
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = -2, Quality = 1
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 12, Quality = 49
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 11, Quality = 9
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 6, Quality = 9
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 5, Quality = 0
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 0, Quality = 49
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = -3, Quality = 0
                },
                new Item {
                    Name = "Alvaro's Test", SellIn = 5, Quality = 0
                }
            };

            // Act
            var gildedRoseCore = new GildedRose(_itemFactory);

            gildedRoseCore.SetItems(initialItems);
            gildedRoseCore.UpdateQuality();

            // Test
            var coreItems = gildedRoseCore.GetItems();

            for (var i = 0; i < expectedResult.Count; i++)
            {
                Assert.Equal(expectedResult[i].Quality, coreItems[i].Quality);
            }
        }
        public void SystemCharacterizationTest()
        {
            // Prepare
            string expectedResult = InitialCharacterizationResult;

            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 = "Aged Brie", SellIn = -1, Quality = 0
                },
                new Item {
                    Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7
                },
                new Item {
                    Name = "Elixir of the Mongoose", SellIn = -1, Quality = 2
                },
                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 = "Backstage passes to a TAFKAL80ETC concert", SellIn = -2, Quality = 2
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = -1, Quality = 6
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 2, Quality = 6
                }
            };

            // Act
            var gildedRoseCore = new GildedRose(_itemFactory);

            gildedRoseCore.SetItems(items);

            var sb = new StringBuilder();

            for (var i = 0; i < 31; i++)
            {
                sb.AppendLine("-------- day " + i + " --------");
                sb.AppendLine("name, sellIn, quality");

                var coreItems = gildedRoseCore.GetItems();

                for (var j = 0; j < coreItems.Count; j++)
                {
                    sb.AppendLine(coreItems[j].Name + ", " + coreItems[j].SellIn + ", " + coreItems[j].Quality);
                }

                sb.AppendLine("");

                gildedRoseCore.UpdateQuality();
            }

            var actualResult = sb.ToString();

            // Test
            Assert.Equal(expectedResult, actualResult);
        }
        public void BackstagePassesCharacterizationTest()
        {
            // Prepare
            List <Item> initialItems = new List <Item>
            {
                // Kata example
                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 = "Backstage passes to a TAFKAL80ETC concert", SellIn = -2, Quality = 2
                },

                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 12, Quality = 50
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 11, Quality = 10
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 6, Quality = 10
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 1
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 50
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -3, Quality = 0
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 0
                }
            };

            var expectedResult = new List <Item>
            {
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 14, Quality = 21
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 9, Quality = 50
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 4, Quality = 50
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -3, Quality = 0
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 11, Quality = 50
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 10, Quality = 11
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 12
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 4, Quality = 4
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 1, Quality = 0
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -4, Quality = 0
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 4, Quality = 3
                }
            };

            // Act
            var gildedRoseCore = new GildedRose(_itemFactory);

            gildedRoseCore.SetItems(initialItems);
            gildedRoseCore.UpdateQuality();

            // Test
            var coreItems = gildedRoseCore.GetItems();

            for (var i = 0; i < expectedResult.Count; i++)
            {
                Assert.Equal(expectedResult[i].Quality, coreItems[i].Quality);
            }
        }