diff --git a/csharpcore/GildedRoseTest.cs b/csharpcore/GildedRoseTest.cs index aa64b0b5..20ef8af4 100644 --- a/csharpcore/GildedRoseTest.cs +++ b/csharpcore/GildedRoseTest.cs @@ -6,12 +6,142 @@ namespace csharpcore public class GildedRoseTest { [Fact] - public void foo() + public void UpdateQuality_NoItems_YieldNoException() { - IList Items = new List { new Item { Name = "foo", SellIn = 0, Quality = 0 } }; - GildedRose app = new GildedRose(Items); + IList items = new List { }; + GildedRose app = new GildedRose(items); + app.UpdateQuality(); - Assert.Equal("fixme", Items[0].Name); + } + + [Fact] + public void UpdateQuality_SulfuraItem_Unchanged() + { + IList items = new List { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 10, Quality = 80 } }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(80, items[0].Quality); + Assert.Equal(10, items[0].SellIn); + } + + [Theory] + [InlineData(7, 7, 8)] + [InlineData(0, 7, 8)] // Issue with Aged Brie that increase Quality twice as fast after SellIn, correct ? + public void UpdateQuality_AgedBrie_QualityIncreases(int beforeSellIn, int beforeQuality, int afterQuality) + { + IList items = new List { new Item { Name = "Aged Brie", SellIn = beforeSellIn, Quality = beforeQuality } }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(afterQuality, items[0].Quality); + Assert.Equal(beforeSellIn - 1, items[0].SellIn); + } + + [Theory] + [InlineData(7, 50, 50)] + [InlineData(0, 50, 50)] + public void UpdateQuality_AgedBrieMaxQuality_QualityToppedAtFifty(int beforeSellIn, int beforeQuality, int afterQuality) + { + IList items = new List { new Item { Name = "Aged Brie", SellIn = beforeSellIn, Quality = beforeQuality } }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(afterQuality, items[0].Quality); + Assert.Equal(beforeSellIn - 1, items[0].SellIn); + } + + [Theory] + [InlineData(11, 7, 8)] + [InlineData(10, 7, 9)] + [InlineData(5, 7, 10)] + public void UpdateQuality_BackStagePass_QualityIncreases(int beforeSellIn, int beforeQuality, int afterQuality) + { + IList items = new List { + new Item { + Name = "Backstage passes to a TAFKAL80ETC concert", + SellIn = beforeSellIn, + Quality = beforeQuality + } + }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(afterQuality, items[0].Quality); + Assert.Equal(beforeSellIn-1, items[0].SellIn); + } + + [Theory] + [InlineData(0, 7, 0)] + [InlineData(0, 50, 0)] + public void UpdateQuality_BackStagePassAfterConcert_QualityZeroed(int beforeSellIn, int beforeQuality, int afterQuality) + { + IList items = new List { + new Item { + Name = "Backstage passes to a TAFKAL80ETC concert", + SellIn = beforeSellIn, + Quality = beforeQuality + } + }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(afterQuality, items[0].Quality); + Assert.Equal(beforeSellIn - 1, items[0].SellIn); + } + + [Theory] + [InlineData(11, 50, 50)] + [InlineData(10, 50, 50)] + [InlineData(5, 50, 50)] + public void UpdateQuality_BackStagePassMaxQuality_QualityToppedAtFifty(int beforeSellIn, int beforeQuality, int afterQuality) + { + IList items = new List { + new Item { + Name = "Backstage passes to a TAFKAL80ETC concert", + SellIn = beforeSellIn, + Quality = beforeQuality + } + }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(afterQuality, items[0].Quality); + Assert.Equal(beforeSellIn - 1, items[0].SellIn); + } + + [Theory] + [InlineData(7, 10, 9)] + [InlineData(0, 10, 8)] + public void UpdateQuality_MiscelaniousItem_QualityDecreases(int beforeSellIn, int beforeQuality, int afterQuality) + { + IList items = new List { new Item { Name = "Wooden Sword", SellIn = beforeSellIn, Quality = beforeQuality } }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(afterQuality, items[0].Quality); + Assert.Equal(beforeSellIn - 1, items[0].SellIn); + } + + [Theory] + [InlineData(7, 0, 0)] + [InlineData(0, 0, 0)] + public void UpdateQuality_MiscelaniousItemMinQuality_QualityCannotGoNegative(int beforeSellIn, int beforeQuality, int afterQuality) + { + IList items = new List { new Item { Name = "Leeroy Jenkins Trinket", SellIn = beforeSellIn, Quality = beforeQuality } }; + GildedRose app = new GildedRose(items); + + app.UpdateQuality(); + + Assert.Equal(afterQuality, items[0].Quality); + Assert.Equal(beforeSellIn - 1, items[0].SellIn); } } } \ No newline at end of file