public void WithAnyItems_QualityNeverBelowMin(string product)
        {
            // Init
            var item = new Item {
                Name = product, SellIn = 11, Quality = 0
            };

            // Act
            var app = new GildedRose(new List <Item> {
                item
            });

            app.UpdateQuality();

            // Assert
            Assert.GreaterOrEqual(item.Quality, MIN_QUALITY);
        }
        public void TestForBackStagePassesOverTheQuality()
        {
            IList <Item> Items = new List <Item>
            {
                new Item
                {
                    Name    = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn  = 1,
                    Quality = 49
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(0, Items[0].SellIn);
            Assert.AreEqual(50, Items[0].Quality);
        }
        public void TestForMaxQualityAgedBrie()
        {
            IList <Item> Items = new List <Item>
            {
                new Item
                {
                    Name    = "Aged Brie",
                    SellIn  = 0,
                    Quality = 49
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(-1, Items[0].SellIn);
            Assert.AreEqual(50, Items[0].Quality);
        }
Esempio n. 4
0
        public void UpdateQuality_AnyItem_NotNegative()
        {
            IList <Item> Items = new List <Item>
            {
                new Item {
                    Name = "Regular Item", SellIn = -1, Quality = 0
                },
                new Item {
                    Name = "Regular Item", SellIn = 5, Quality = 0
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(0, Items[0].Quality);
            Assert.AreEqual(0, Items[1].Quality);
        }
        public void IncreasesAgedBrieQuality()
        {
            //Arrang
            IList <Item> items = new List <Item> {
                new Item {
                    Name = "Aged Brie", SellIn = 2, Quality = 3
                }
            };

            GildedRose app = new GildedRose(items);

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

            //Assert
            Assert.AreEqual(4, startQuality);
        }
Esempio n. 6
0
        public void BackStagePassQualityShouldNotBeMoreThanFifty()
        {
            int          quality           = 100;
            int          daysBeforeConcert = 9;
            int          increase          = 1;
            IList <Item> items             = new List <Item> {
                new Item {
                    Name    = ItemName.BackstagePass,
                    SellIn  = daysBeforeConcert,
                    Quality = quality
                }
            };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
            Assert.AreEqual(50, items[0].Quality);
        }
        public void GivenValidConcertTicketItemsWhenUpdateIsCalledThenSellInAndQualityShouldUpdateCorrectly()
        {
            var 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 = 2, Quality = 10
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 2, Quality = 48
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 17, Quality = 5
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 10, Quality = 5
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -1, Quality = 50
                },
                new Item {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 1, Quality = 50
                },
            };

            var app = new GildedRose(items);

            app.UpdateQuality();

            Assert.AreEqual(13, items[0].Quality);
            Assert.AreEqual(4, items[0].SellIn);
            Assert.AreEqual(13, items[1].Quality);
            Assert.AreEqual(1, items[1].SellIn);
            Assert.AreEqual(50, items[2].Quality);
            Assert.AreEqual(1, items[2].SellIn);
            Assert.AreEqual(6, items[3].Quality);
            Assert.AreEqual(16, items[3].SellIn);
            Assert.AreEqual(7, items[4].Quality);
            Assert.AreEqual(9, items[4].SellIn);
            Assert.AreEqual(0, items[5].Quality);
            Assert.AreEqual(-2, items[5].SellIn);
            Assert.AreEqual(50, items[6].Quality);
            Assert.AreEqual(0, items[6].SellIn);
        }
Esempio n. 8
0
        public void AgedBrieQualityIncreasesByTwoAfterSellIn()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getAgedBrie(-1, 5)
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(originalQuality + 2, Items[0].Quality);
        }
Esempio n. 9
0
        public void AgedBrieQualityNotIncrementedAboveFifty()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getAgedBrie(-1, 50)
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(50, Items[0].Quality);
        }
        public void QualityIsNeverNegative()
        {
            int         initialQuality = 50;
            List <Item> items          = new List <Item> {
                new Item {
                    Name = "foo", SellIn = 20, Quality = initialQuality
                }
            };

            GildedRose app = new GildedRose(items);

            for (int i = 0; i < 200; i++)
            {
                app.UpdateQuality();
            }
            items[0].Quality.Should().BeGreaterOrEqualTo(0);
        }
Esempio n. 11
0
        public void ItemQualityNotDecrementedBelowZero()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getNormalItem(-1, 0)
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(0, Items[0].Quality);
        }
Esempio n. 12
0
        public void QualityDegradationTwoItems()
        {
            IList <Item> items = new List <Item>
            {
                new Item {
                    Name = "Good", SellIn = 9, Quality = 12
                },
                new Item {
                    Name = "Good2", SellIn = 15, Quality = 8
                }
            };
            GildedRose app = new GildedRose(items);

            app.UpdateQuality();
            Assert.That(items.Single(i => i.Name == "Good").Quality, Is.EqualTo(11));
            Assert.That(items.Single(i => i.Name == "Good2").Quality, Is.EqualTo(7));
        }
Esempio n. 13
0
        public void LowerItemValues()
        {
            IList <Item> Items = new List <Item> {
                new Item {
                    Name = "foo", SellIn = 10, Quality = 10
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();

            foreach (var item in Items)
            {
                Assert.AreEqual(9, item.SellIn);
                Assert.AreEqual(9, item.Quality);
            }
        }
Esempio n. 14
0
        public void GildedRose_UpdateQuality_BackstagePassesIncreasesBy2WithAge_success()
        {
            bool         hasBeenRunToday = false;
            int          quality         = 15;
            IList <Item> Items           = new List <Item> {
                new Item {
                    Name   = "Backstage passes to a TAFKAL80ETC concert",
                    SellIn = 10, Quality = quality
                }
            };
            GildedRose app             = new GildedRose(Items, hasBeenRunToday);
            int        increment       = 2;                   // backstage quality increase by 2 when 10 to 6 days to concert
            int        expectedQuality = quality + increment; // this is with the assumption that incrementing of quality of the item is by "increment"

            app.UpdateQuality();
            Assert.AreEqual(expectedQuality, Items[0].Quality);
        }
Esempio n. 15
0
        public void QualityIsCapped()
        {
            var item = new Item {
                Name = Brie, SellIn = InitialSellIn, Quality = MaxQuality
            };
            IList <Item> Items = new List <Item> {
                item
            };
            GildedRose app = new GildedRose(Items);

            for (int i = 1; i <= 20; i++)
            {
                app.UpdateQuality();
            }

            Assert.AreEqual(MaxQuality, item.Quality);
        }
Esempio n. 16
0
        public void SulfurasSellInNotDecremented()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getSulfuras()
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(originalSellIn, Items[0].SellIn);
        }
Esempio n. 17
0
        public void SellByDecrementsEachDay()
        {
            var item = new Item {
                Name = "foo", SellIn = InitialSellIn, Quality = InitialHighQuality
            };
            IList <Item> Items = new List <Item> {
                item
            };
            GildedRose app = new GildedRose(Items);

            for (int i = 1; i <= 50; i++)
            {
                app.UpdateQuality();
            }

            Assert.AreEqual(-40, item.SellIn);
        }
Esempio n. 18
0
        public void BackstagePassesSellInDecrementedByOne()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getBackstagePasses()
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(originalSellIn - 1, Items[0].SellIn);
        }
Esempio n. 19
0
        public void UpdateQuality_OnSulfuras_QualityStaysSame(int amountOfUpdates)
        {
            int itemQuality = 5;
            int sellIn      = 15;
            InventoryProduct         item  = ItemBuilder.Sulfuras().WithSellIn(sellIn).WithQuality(itemQuality).Build();
            IList <InventoryProduct> Items = new List <InventoryProduct> {
                item
            };
            GildedRose app = new GildedRose(Items);

            for (int i = 0; i < amountOfUpdates; i++)
            {
                app.UpdateQuality();
            }
            Assert.AreEqual(itemQuality, Items[0].Quality);
            Assert.AreEqual(sellIn, Items[0].SellIn);
        }
Esempio n. 20
0
        public void BackstagePassesQualityToZeroAfterSellIn()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getBackstagePasses(-2, 5)
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(0, Items[0].Quality);
        }
Esempio n. 21
0
        public void UpdateQuality_AgedSellDateNotPassed_IncreasesQuality()
        {
            IList <Item> Items = new List <Item>
            {
                new Item {
                    Name = "Aged Brie", SellIn = 3, Quality = 10
                },
                new Item {
                    Name = "Aged Brie", SellIn = 5, Quality = 50
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(11, Items[0].Quality);
            Assert.AreEqual(50, Items[1].Quality);
        }
Esempio n. 22
0
        public void BackstagePassesQualityUpBy3At5Days()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getBackstagePasses(5, 5)
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(originalQuality + 3, Items[0].Quality);
        }
        public void NoChangeSellInOfSulfuras()
        {
            //Arrang
            IList <Item> items = new List <Item> {
                new Item {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80
                }
            };

            GildedRose app = new GildedRose(items);

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

            //Assert
            Assert.AreEqual(0, startSellIn);
        }
Esempio n. 24
0
        public void ConjuredItemDegradesBy4AfterSellIn()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getConjuredItem(-1, 5)
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(originalQuality - 4, Items[0].Quality);
        }
        public void TestForSulfurasHandOfRagnaros()
        {
            IList <Item> Items = new List <Item>
            {
                new Item
                {
                    Name    = "Sulfuras, Hand of Ragnaros",
                    SellIn  = 0,
                    Quality = 80
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(0, Items[0].SellIn);
            Assert.AreEqual(80, Items[0].Quality);
        }
Esempio n. 26
0
        public void NormalItemDecrementSellInByOne()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getNormalItem()
            };

            int        originalSellIn  = Items[0].SellIn;
            int        originalQuality = Items[0].Quality;
            GildedRose GR = new GildedRose(Items);

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(originalSellIn - 1, Items[0].SellIn);
        }
        public void TestForConjuredManaCakeAfterSellInDatePass()
        {
            IList <Item> Items = new List <Item>
            {
                new Item
                {
                    Name    = "Conjured Mana Cake",
                    SellIn  = -1,
                    Quality = 6
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(-2, Items[0].SellIn);
            Assert.AreEqual(2, Items[0].Quality);
        }
Esempio n. 28
0
        public void NormalItemDecrementQualityByTwoAfterSellIn()
        {
            //Arrange
            IList <Item> Items = new List <Item> {
                this.getNormalItem(-1, 5)
            };
            GildedRose GR = new GildedRose(Items);

            int originalSellIn  = Items[0].SellIn;
            int originalQuality = Items[0].Quality;

            //Act
            GR.UpdateQuality();

            //Assert
            Assert.AreEqual(originalQuality - 2, Items[0].Quality);
        }
        public void TestForRegularItem()
        {
            IList <Item> Items = new List <Item>
            {
                new Item
                {
                    Name    = "+5 Dexterity Vest",
                    SellIn  = 10,
                    Quality = 20
                }
            };
            GildedRose app = new GildedRose(Items);

            app.UpdateQuality();
            Assert.AreEqual(9, Items[0].SellIn);
            Assert.AreEqual(19, Items[0].Quality);
        }
        public void WhenItemIsBackstage_QualityIsIncreasing(int sellInn, int increaseSpeed)
        {
            // Init
            int initialQuality = 25;
            var item           = new Item {
                Name = ProductLibrary.PRODUCT_BACKSTAGE_PASSES, SellIn = sellInn, Quality = initialQuality
            };
            var app = new GildedRose(new List <Item> {
                item
            });

            // Act
            app.UpdateQuality();

            // Assert
            Assert.AreEqual(initialQuality + increaseSpeed, item.Quality);
        }