Exemplo n.º 1
0
        public void Item_NeverDegrades_ToBelowZero(int quality)
        {
            var sellIn = -2;

            IList <Item> Items = new List <Item>
            {
                new Item {
                    Name = "Regular Item", SellIn = sellIn, Quality = quality
                },
                new Item {
                    Name = ConjuredName, SellIn = sellIn, Quality = quality
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Assert.AreEqual(0, Items[0].Quality);
        }
Exemplo n.º 2
0
        public void TestRegularDegrade()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Regular", SellIn = 8, Quality = 20
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(19, Items[0].Quality);
            Assert.AreEqual(7, Items[0].SellIn);

            Items[0].SellIn = 0;
            app.UpdateQuality();
            Assert.AreEqual(17, Items[0].Quality);
            app.UpdateQuality();
            Assert.AreEqual(15, Items[0].Quality);
        }
Exemplo n.º 3
0
        public void TestConjured()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Conjured Something", SellIn = 8, Quality = 20
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(18, Items[0].Quality);
            Assert.AreEqual(7, Items[0].SellIn);

            Items[0].SellIn = 0;
            app.UpdateQuality();
            Assert.AreEqual(14, Items[0].Quality);
            app.UpdateQuality();
            Assert.AreEqual(10, Items[0].Quality);
        }
        public void updateQuality()
        {
            //Arrange
            IList <Item> resultItems   = createItemsForTesting();
            IList <Item> expectedItems = createExpectedItemsForTesting();

            //Act
            GildedRose app = new GildedRose(resultItems);

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

            //Assert
            for (int i = 0; i < resultItems.Count; i++)
            {
                Assert.True(resultItems[i].Equals(expectedItems[i]));
            }
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");

            IList <Item> Items = AddItems.Items();

            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]);
                }
                Console.WriteLine("");
                app.UpdateQuality();
            }
        }
Exemplo n.º 6
0
        public void SulfurasDoesNotChange()
        {
            IList <Item> Items = new List <Item> {
                new Item()
                {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            if (Items[0].Name == "Sulfuras, Hand of Ragnaros")
            {
                for (int i = 0; i < 31; i++)
                {
                    Assert.AreEqual(Items[0].Quality, 80);
                    app.UpdateQuality();
                }
            }
        }
        public void ReduceSellInItem()
        {
            //Arrang
            IList <Item> items = new List <Item> {
                new Item {
                    Name = "foo", SellIn = 10, Quality = 20
                }
            };

            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
            int startSellIn = items[0].SellIn;

            //Act


            //Assert
            Assert.AreEqual(9, startSellIn);
        }
Exemplo n.º 8
0
        public void GildedRoseTest_ConjuredItemCorrectUpdateAfterOneDay()
        {
            int originalSellIn = 5;
            int updatedSellIn  = 4;

            int originalQuality = 20;
            int updatedQuality  = 18;

            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Conjured Mana Cake", SellIn = originalSellIn, Quality = originalQuality
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Assert.AreEqual(Items[0].SellIn, updatedSellIn);
            Assert.AreEqual(Items[0].Quality, updatedQuality);
        }
Exemplo n.º 9
0
        public void GildedRoseTest_BackstagePassCorrectUpdateAfterConcertPassed()
        {
            int originalSellIn = 0;
            int updatedSellIn  = -1;

            int originalQuality = 10;
            int updatedQuality  = 0;

            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = originalSellIn, Quality = originalQuality
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Assert.AreEqual(Items[0].SellIn, updatedSellIn);
            Assert.AreEqual(Items[0].Quality, updatedQuality);
        }
Exemplo n.º 10
0
        public void GildedRoseTest_AgedBrieCorrectUpdateAfterQualityFifty()
        {
            int originalSellIn = 5;
            int updatedSellIn  = 4;

            int originalQuality = 50;
            int updatedQuality  = 50;

            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Aged Brie", SellIn = originalSellIn, Quality = originalQuality
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Assert.AreEqual(Items[0].SellIn, updatedSellIn);
            Assert.AreEqual(Items[0].Quality, updatedQuality);
        }
        public void QualityOfBackstageincreasesByOneLessSix()
        {
            //Arrang
            IList <Item> items = new List <Item> {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 6,
                    Quality = 20
                }
            };

            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
            int startQuality = items[0].Quality;

            //Assert
            Assert.AreEqual(22, startQuality);
        }
Exemplo n.º 12
0
        public void GildedRoseTest_LegendaryItemCorrectUpdateAfterOneDay()
        {
            int originalSellIn = 5;
            int updatedSellIn  = 5;

            int originalQuality = 80;
            int updatedQuality  = 80;

            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = originalSellIn, Quality = originalQuality
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Assert.AreEqual(Items[0].SellIn, updatedSellIn);
            Assert.AreEqual(Items[0].Quality, updatedQuality);
        }
        public void SetQualityOfBackstagToZeroWhenSillinHazZero()
        {
            //Arrang
            IList <Item> items = new List <Item> {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 0,
                    Quality = 20
                }
            };

            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
            int startQuality = items[0].Quality;

            //Assert
            Assert.AreEqual(0, startQuality);
        }
Exemplo n.º 14
0
        public void EveryItemQuailtyIsGreaterOrEqualTo50()
        {
            IList <Item> Items = AddItems.Items();

            var app = new GildedRose(Items);

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

            foreach (var item in Items)
            {
                //Sulfuras quality is 80 which is OK, Don't need to check that
                if (item.Name != "Sulfuras, Hand of Ragnaros")
                {
                    Assert.GreaterOrEqual(item.Quality, 0);
                }
            }
        }
Exemplo n.º 15
0
        public void ConjuredItemsDecayFourTimesAsFastAfterSellInPasses()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = Conjured, SellIn = 1, Quality = 20
                }
            };
            GildedRose app = new GildedRose(Items);

            Assert.AreEqual(20, Items[0].Quality);

            app.UpdateQuality();
            Assert.AreEqual(18, Items[0].Quality);

            app.UpdateQuality();
            Assert.AreEqual(14, Items[0].Quality);

            app.UpdateQuality();
            Assert.AreEqual(10, Items[0].Quality);
        }
Exemplo n.º 16
0
        public void ConjuredItemsDecayTwiceAsFastBeforeSellInPasses()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = Conjured, SellIn = 3, Quality = 20
                }
            };
            GildedRose app = new GildedRose(Items);

            Assert.AreEqual(20, Items[0].Quality);

            app.UpdateQuality();
            Assert.AreEqual(18, Items[0].Quality);

            app.UpdateQuality();
            Assert.AreEqual(16, Items[0].Quality);

            app.UpdateQuality();
            Assert.AreEqual(14, Items[0].Quality);
        }
Exemplo n.º 17
0
        public void GildedRose_UpdateQuality_ConjuredItem_success()
        {
            // in the production situation, the value for
            // hasBeenRunToday would be taken from some persisted medium like
            // a database. We use a hard coded value here just for the sake of
            // test.
            bool         hasBeenRunToday = false;
            IList <Item> Items           = new List <Item> {
                new Item {
                    Name = "Conjured Item", SellIn = 10, Quality = 30
                }
            };
            GildedRose app = new GildedRose(Items, hasBeenRunToday);

            app.UpdateQuality();
            int expectedQuality = 28; // this is with the assumption that decrementing of quality the

            // item is by 2
            Assert.AreEqual(expectedQuality, Items[0].Quality);
        }
        public void ReduceQualityItem()
        {
            IList <Item> items = new List <Item> {
                new Item {
                    Name = "foo", SellIn = 10, Quality = 20
                }
            };

            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
            int startQuality = items[0].Quality;

            //Act


            //Assert
            items[0].Quality.Equals(2);
            Assert.AreEqual(19, startQuality);
        }
Exemplo n.º 19
0
        public void TestBackstagePassesItem()
        {
            IList <Item> items = new List <Item> {
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 12, Quality = 6
                }
            };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
            Assert.AreEqual("Backstage passes to a TAFKAL80ETC concert", items[0].Name);
            Assert.AreEqual(11, items[0].SellIn);
            Assert.AreEqual(7, items[0].Quality);

            app.UpdateQuality();
            app.UpdateQuality();
            Assert.AreEqual(9, items[0].SellIn);
            Assert.AreEqual(10, items[0].Quality);

            app.UpdateQuality();
            Assert.AreEqual(8, items[0].SellIn);
            Assert.AreEqual(12, items[0].Quality);

            app.UpdateQuality();
            app.UpdateQuality();
            app.UpdateQuality();
            Assert.AreEqual(5, items[0].SellIn);
            Assert.AreEqual(18, items[0].Quality);

            app.UpdateQuality();
            app.UpdateQuality();
            Assert.AreEqual(3, items[0].SellIn);
            Assert.AreEqual(24, items[0].Quality);

            app.UpdateQuality();
            app.UpdateQuality();
            app.UpdateQuality();
            app.UpdateQuality();
            Assert.AreEqual(-1, items[0].SellIn);
            Assert.AreEqual(0, items[0].Quality);
        }
Exemplo n.º 20
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);

            app.UpdateQuality();

            Items[0].SellIn.Should().Be(9);
            Items[1].SellIn.Should().Be(1);
            Items[2].SellIn.Should().Be(4);
            Items[3].SellIn.Should().Be(0);
            Items[4].SellIn.Should().Be(14);
            Items[5].SellIn.Should().Be(2);

            Items[0].Quality.Should().Be(19);
            Items[1].Quality.Should().Be(1);
            Items[2].Quality.Should().Be(6);
            Items[3].Quality.Should().Be(80);
            Items[4].Quality.Should().Be(21);
            Items[5].Quality.Should().Be(4);
        }
        public void GivenValidConjuredItemsWhenUpdateIsCalledThenSellInAndQualityShouldUpdateCorrectly()
        {
            var items = new List <Item>
            {
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 5, Quality = 0
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 50, Quality = 50
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 2, Quality = 10
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 10, Quality = 10
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = 1, Quality = 10
                },
                new Item {
                    Name = "Conjured Mana Cake", SellIn = -1, Quality = 10
                },
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            Assert.AreEqual(0, items[0].Quality);
            Assert.AreEqual(4, items[0].SellIn);
            Assert.AreEqual(48, items[1].Quality);
            Assert.AreEqual(49, items[1].SellIn);
            Assert.AreEqual(8, items[2].Quality);
            Assert.AreEqual(1, items[2].SellIn);
            Assert.AreEqual(8, items[3].Quality);
            Assert.AreEqual(9, items[3].SellIn);
            Assert.AreEqual(8, items[4].Quality);
            Assert.AreEqual(0, items[4].SellIn);
            Assert.AreEqual(6, items[5].Quality);
            Assert.AreEqual(-2, items[5].SellIn);
        }
        public void UpdateQuality_ForStandardItemAfter1DayAndSellInHigherThen0_QualityShouldDecreases()
        {
            var item = new Item
            {
                Name    = "Item",
                SellIn  = 1,
                Quality = 50
            };
            var items = new List <Item>
            {
                item
            };

            var app = new GildedRose(items);

            // Act
            app.UpdateQuality();

            // Assert
            Assert.AreEqual(49, item.Quality);
        }
Exemplo n.º 23
0
        public void TestAgedBrie()
        {
            var items = new List <IItem> {
                new AgedBrieItem {
                    Name = "Aged Brie", SellIn = 1, Quality = 1
                }
            };
            var app = new GildedRose(items);

            app.UpdateQuality();

            Assert.AreEqual("Aged Brie", items[0].Name);
            Assert.AreEqual(0, items[0].SellIn);
            Assert.AreEqual(2, items[0].Quality);

            app.UpdateQuality();

            Assert.AreEqual("Aged Brie", items[0].Name);
            Assert.AreEqual(-1, items[0].SellIn);
            Assert.AreEqual(3, items[0].Quality);
        }
Exemplo n.º 24
0
        public void CheckLegendary()
        {
            IList <Item> Items = new List <Item>
            {
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 11, Quality = 80
                },
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 23, Quality = 80
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(80, Items[0].Quality);
            for (int i = 0; i < 1000; i++)
            {
                app.UpdateQuality();
            }
            Assert.AreEqual(80, Items[0].Quality);
        }
Exemplo n.º 25
0
        public void UpdateQuality_BackstagePassQualityUpperLimitExceededWhenFiveOrLessDaysBeforeConcert_QualityStaysAtLimit()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = GildedRose.BACKSTAGE, SellIn = 5, Quality = QualityUpperLimit - 2
                },
                new Item {
                    Name = GildedRose.BACKSTAGE, SellIn = 3, Quality = QualityUpperLimit - 1
                },
                new Item {
                    Name = GildedRose.BACKSTAGE, SellIn = 1, Quality = QualityUpperLimit
                },
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            Assert.AreEqual(QualityUpperLimit, Items[0].Quality);
            Assert.AreEqual(QualityUpperLimit, Items[1].Quality);
            Assert.AreEqual(QualityUpperLimit, Items[2].Quality);
        }
Exemplo n.º 26
0
        public void QualityOf_AgedBrie_DoesntGoAbove50()
        {
            IList <Item> Items = new List <Item>
            {
                new Item {
                    Name = "Aged Brie", SellIn = 3, Quality = 49
                },
                new Item {
                    Name = "Aged Brie", SellIn = 0, Quality = 49
                }
            };
            GildedRose app = new GildedRose(Items);


            for (var daysPassed = 1; daysPassed <= 3; daysPassed++)
            {
                app.UpdateStock();
                Assert.AreEqual(50, Items[0].Quality);
                Assert.AreEqual(50, Items[1].Quality);
            }
        }
Exemplo n.º 27
0
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");
            IList <Item> items = CreateItems();

            var gildedRose = new GildedRose(items);

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

                foreach (var item in items)
                {
                    Console.WriteLine(item);
                }

                Console.WriteLine("");
                gildedRose.UpdateQuality();
            }
        }
        public void UpdateQuality_ForConjuredItemAfter1DayAndSellInGreaterThen0AndQuantityIsGraterThen2_QualityShouldDecreasesBy2()
        {
            var backstagePassItem = new Item
            {
                Name    = "Conjured Mana Cake",
                SellIn  = 3,
                Quality = 10
            };
            var items = new List <Item>
            {
                backstagePassItem
            };

            var app = new GildedRose(items);

            // Act
            app.UpdateQuality();

            // Assert
            Assert.AreEqual(8, backstagePassItem.Quality);
        }
Exemplo n.º 29
0
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");

            IList <BaseItem> items = GetItems();

            GildedRose app = new GildedRose(items);

            for (int i = 0; i < 31; i++)
            {
                Console.WriteLine("-------- day " + i + " --------");
                Console.WriteLine("name, sellIn, quality");
                foreach (dynamic item in items)
                {
                    Console.WriteLine(item.Name + ", " + item.SellIn + ", " + item.Quality);
                }
                Console.WriteLine("");
                app.UpdateQuality();
            }
            Console.ReadLine();
        }
        public void UpdateQuality_ForBackStagePassAfter1DayAndSellInLessThen0_QualityShouldEquals0()
        {
            var backstagePassItem = new Item
            {
                Name    = "Backstage passes to a TAFKAL80ETC concert",
                SellIn  = -1,
                Quality = 10
            };
            var items = new List <Item>
            {
                backstagePassItem
            };

            var app = new GildedRose(items);

            // Act
            app.UpdateQuality();

            // Assert
            Assert.AreEqual(0, backstagePassItem.Quality);
        }