public void Should_Never_Have_Sulfuras_Decrease_In_Quality(string nameItem1, string nameItem2, string nameItem3) { IList <int> sellIns = new List <int> { 0, -2, 3, 4, 5, -7, -6 }; IList <int> qualities = new List <int> { 0, 0, 0, 5, 4, 1, 8 }; IList <Item> items = new List <Item>(); string currentName = nameItem1; for (var i = 0; i < qualities.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = sellIns[i], Quality = qualities[i] }); } GildedRose app = new GildedRose(items); app.UpdateQuality(); for (var i = 0; i < items.Count; i++) { if (items[i].Name.Contains("Sulfuras")) { Assert.Equal(qualities[i], items[i].Quality); } } }
public void Should_Increase_Quality_If_Age_Brie_Gets_Older(string nameItem1, string nameItem2, string nameItem3) { IList <int> sellIns = new List <int> { 0, -2, 3, 4, 5, -7, -6 }; IList <int> qualities = new List <int> { 0, 0, 0, 5, 4, 1, 8 }; IList <Item> items = new List <Item>(); string currentName = nameItem1; for (var i = 0; i < qualities.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = sellIns[i], Quality = qualities[i] }); } GildedRose app = new GildedRose(items); app.UpdateQuality(); for (var i = 0; i < items.Count; i++) { if (items[i].Name.Contains("Aged Brie")) { Assert.True(items[i].Quality - qualities[i] > 0); } } }
public void Should_Lower_SellIn_After_Update_Quality_If_Not_Sulfuras(string nameItem1, string nameItem2, string nameItem3) { IList <int> sellIns = new List <int> { 0, -2, 3, 4, 5, -7, -6 }; IList <int> qualities = new List <int> { 0, 0, 0, 5, 34, 11, 28 }; IList <Item> items = new List <Item>(); string currentName = nameItem1; for (var i = 0; i < qualities.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = sellIns[i], Quality = qualities[i] }); } GildedRose app = new GildedRose(items); app.UpdateQuality(); for (var i = 0; i < items.Count; i++) { if (!items[i].Name.Contains("Sulfuras")) { Assert.Equal(items[i].SellIn, sellIns[i] - 1); } } }
public void Should_Return_First_Item_Name(string nameItem1, string nameItem2, string nameItem3) { IList <int> sellIns = new List <int> { 0, -2, 3, 4, 5, -7, -6 }; IList <int> qualities = new List <int> { 0, 0, 0, 5, 4, 21, 38 }; IList <Item> items = new List <Item>(); string currentName = nameItem1; for (var i = 0; i < qualities.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = sellIns[i], Quality = qualities[i] }); } GildedRose app = new GildedRose(items); app.UpdateQuality(); Assert.Equal(nameItem1, items[0].Name); Assert.Equal(nameItem2, items[1].Name); Assert.Equal(nameItem3, items[2].Name); Assert.Equal(nameItem1, items[3].Name); Assert.Equal(nameItem2, items[4].Name); Assert.Equal(nameItem3, items[5].Name); Assert.Equal(nameItem1, items[6].Name); }
public void Should_Never_Have_Quality_More_Than_50(string nameItem1, string nameItem2, string nameItem3) { IList <int> sellIns = new List <int> { 0, -2, 3, 4, 5, -7, -6 }; IList <int> qualities = new List <int> { 0, 0, 0, 5, 4, 1, 8 }; IList <Item> items = new List <Item>(); string currentName = nameItem1; for (var i = 0; i < qualities.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = sellIns[i], Quality = qualities[i] }); } GildedRose app = new GildedRose(items); app.UpdateQuality(); foreach (var item in items) { Assert.True(item.Quality <= 50); } }
public void Should_Have_Sellin_Value_On_Each_Item(string nameItem1, string nameItem2, string nameItem3) { IList <int> sellIns = new List <int> { 0, -2, 3, 4, 5, -7, -6 }; IList <int> qualities = new List <int> { 0, 0, 0, 5, 4, 21, 38 }; IList <Item> items = new List <Item>(); string currentName = nameItem1; for (var i = 0; i < qualities.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = sellIns[i], Quality = qualities[i] }); } GildedRose app = new GildedRose(items); app.UpdateQuality(); foreach (var item in items) { Assert.True(item.GetType().GetProperty("SellIn") != null); } }
public void Should_Degrade_Quality_Twice_After_SellIn_Zero(string nameItem1, string nameItem2, string nameItem3) { IList <int> beforeSellIns = new List <int> { 4, 2, 5, 1, 0 }; IList <int> afterSellIns = new List <int> { -1, -9, -7, -6 }; IList <int> beforeSellinQualities = new List <int> { 0, 2, 3, 5, 1 }; IList <int> afterSellinQualities = new List <int> { 0, 2, 3, 5 }; IList <Item> items = new List <Item>(); string currentName = nameItem1; for (var i = 0; i < beforeSellIns.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = beforeSellIns[i], Quality = beforeSellinQualities[i] }); } for (var i = 0; i < afterSellIns.Count; i++) { if (currentName == nameItem1) { if (i != 0) { currentName = nameItem2; } } else if (currentName == nameItem2) { currentName = nameItem3; } else { currentName = nameItem1; } items.Add(new Item { Name = currentName, SellIn = afterSellIns[i], Quality = afterSellinQualities[i] }); } GildedRose app = new GildedRose(items); app.UpdateQuality(); IList <int> updatedQualitiesBeforeSellIn = new List <int>(); IList <int> updatedQualitiesAfterSellIn = new List <int>(); for (var i = 0; i < items.Count; i++) { if (i < 5) { updatedQualitiesBeforeSellIn.Add(items[i].Quality); } else { updatedQualitiesAfterSellIn.Add(items[i].Quality); } } for (var i = 0; i < beforeSellinQualities.Count; i++) { Assert.Equal(beforeSellinQualities[i] - updatedQualitiesBeforeSellIn[i], beforeSellinQualities[i] - updatedQualitiesBeforeSellIn[i]); } for (var i = 0; i < afterSellinQualities.Count; i++) { Assert.Equal((beforeSellinQualities[i] - updatedQualitiesBeforeSellIn[i]) * 2, afterSellinQualities[i] - updatedQualitiesAfterSellIn[i]); } }