diff --git a/GildedRose.cs b/GildedRose.cs index b2115f5..36e3ecf 100644 --- a/GildedRose.cs +++ b/GildedRose.cs @@ -45,9 +45,8 @@ namespace csharpcore private static void UpdateConjuredCake(Item item) { - // TODO - // Decrease quality twice when sell date is passed - var qualityDecrement = item.SellIn > 0 ? 1 : 2; + // Decrease quality twice as fast as normal items + var qualityDecrement = item.SellIn > 0 ? 2 : 4; item.Quality = Math.Max(item.Quality - qualityDecrement, 0); } diff --git a/test/ApprovalTest.ThirtyDays.approved.txt b/test/ApprovalTest.ThirtyDays.approved.txt index cd66984..f80af4e 100644 --- a/test/ApprovalTest.ThirtyDays.approved.txt +++ b/test/ApprovalTest.ThirtyDays.approved.txt @@ -21,7 +21,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 14, 21 Backstage passes to a TAFKAL80ETC concert, 9, 50 Backstage passes to a TAFKAL80ETC concert, 4, 50 -Conjured Mana Cake, 2, 5 +Conjured Mana Cake, 2, 4 -------- day 2 -------- name, sellIn, quality @@ -33,7 +33,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 13, 22 Backstage passes to a TAFKAL80ETC concert, 8, 50 Backstage passes to a TAFKAL80ETC concert, 3, 50 -Conjured Mana Cake, 1, 4 +Conjured Mana Cake, 1, 2 -------- day 3 -------- name, sellIn, quality @@ -45,7 +45,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 12, 23 Backstage passes to a TAFKAL80ETC concert, 7, 50 Backstage passes to a TAFKAL80ETC concert, 2, 50 -Conjured Mana Cake, 0, 3 +Conjured Mana Cake, 0, 0 -------- day 4 -------- name, sellIn, quality @@ -57,7 +57,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 11, 24 Backstage passes to a TAFKAL80ETC concert, 6, 50 Backstage passes to a TAFKAL80ETC concert, 1, 50 -Conjured Mana Cake, -1, 1 +Conjured Mana Cake, -1, 0 -------- day 5 -------- name, sellIn, quality diff --git a/test/ConjuredTest.cs b/test/ConjuredTest.cs index 93760b3..78c7ec4 100644 --- a/test/ConjuredTest.cs +++ b/test/ConjuredTest.cs @@ -15,17 +15,20 @@ namespace csharpcore _rose =new GildedRose(_items); } - //[Fact] - public void ShouldDecreaseInQuality() + [Theory] + [InlineData(3, 2, 1)] + [InlineData(5, 1, 3)] + [InlineData(5, 0, 1)] + public void ShouldDecreaseInQualityTwiceAsFastAsNormalItems(int inQuality, int sellInDays, int expectedQuality) { - var item = GenerateItem(3, 2); + var item = GenerateItem(inQuality, sellInDays); _items.Add(item); _rose.UpdateQuality(); - Assert.Equal(1, item.Quality); - Assert.Equal(1, item.SellIn); + Assert.Equal(sellInDays - 1, item.SellIn); + Assert.Equal(expectedQuality, item.Quality); } - + public Item GenerateItem(int quality, int sellInDays) => new Item {Name = "Conjured Mana Cake", Quality = quality, SellIn = sellInDays}; }