public void UpdateItem() { for (var i = 0; i < Items.Count; i++) { Items[i].Quality = QualityUpdater.GetUpdatedQuality(Items[i]); Items[i].SellIn = Math.Max(Items[i].SellIn - 1, 0); } }
public void ReturnsBrieQualityManager() { IList <Item> Items = new List <Item> { new Item { Name = "Aged Brie", SellIn = 0, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); Assert.AreEqual(qualityUpdater.GetType(), typeof(AgedBrieQualityUpdater)); }
public void BrieQualityGoesUpOnce() { IList <Item> Items = new List <Item> { new Item { Name = "Aged Brie", SellIn = 100, Quality = 0 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); qualityUpdater.UpdateItemQuality(Items[0]); Assert.AreEqual(1, Items[0].Quality); }
public void ReturnsStagePassQualityManager() { IList <Item> Items = new List <Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); Assert.AreEqual(qualityUpdater.GetType(), typeof(BackstagePassQualityUpdater)); }
public void ReturnsRegularQualityManager() { IList <Item> Items = new List <Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 0, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); Assert.AreEqual(qualityUpdater.GetType(), typeof(QualityUpdater)); }
public void ReturnsSulfurasQualityManager() { IList <Item> Items = new List <Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); Assert.AreEqual(qualityUpdater.GetType(), typeof(SulfurasQualityUpdater)); }
public void RegularItemLosesQualityOnce() { IList <Item> Items = new List <Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); qualityUpdater.UpdateItemQuality(Items[0]); Assert.AreEqual(19, Items[0].Quality); }
public void ConjuredItemLosesQualityOnce() { IList <Item> Items = new List <Item> { new Item { Name = "Conjured Kudzu", SellIn = 10, Quality = 20 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); qualityUpdater.UpdateItemQuality(Items[0]); Assert.AreEqual(18, Items[0].Quality); }
public void StagePassQualityGoesUpOverTime() { IList <Item> Items = new List <Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 100, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); qualityUpdater.UpdateItemQuality(Items[0]); Assert.AreEqual(11, Items[0].Quality); }
public void StagePassQualityIncreasesFasterWithFiveDaysLeft() { IList <Item> Items = new List <Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); qualityUpdater.UpdateItemQuality(Items[0]); Assert.AreEqual(13, Items[0].Quality); }
public void RegularItemLosesQualityMultipleTimes() { for (int numDaysToSimulate = 0; numDaysToSimulate < 30; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 50, Quality = 40 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.AreEqual(40 - numDaysToSimulate, Items[0].Quality); } }
public void ConjuredItemLosesQualityMultipleTimes() { for (int numDaysToSimulate = 0; numDaysToSimulate < 15; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "Conjured Kudzu", SellIn = 50, Quality = 40 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.AreEqual(40 - (2 * numDaysToSimulate), Items[0].Quality); } }
public void RegularItemQualityNeverBelow0() { for (int numDaysToSimulate = 0; numDaysToSimulate < 30; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 10, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.GreaterOrEqual(Items[0].Quality, 0); } }
public void RegularItemQualityDecreasesTwiceAsFastPastSellInDate() { for (int numDaysToSimulate = 0; numDaysToSimulate < 10; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 0, Quality = 50 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.AreEqual(50 - (2 * numDaysToSimulate), Items[0].Quality); } }
public void StagePassQualityNeverAbove50() { for (int numDaysToSimulate = 0; numDaysToSimulate < 30; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 15, Quality = 40 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.LessOrEqual(Items[0].Quality, 50); } }
public void SulfurasImmutableQualityOverTime() { for (int numDaysToSimulate = 0; numDaysToSimulate < 30; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 20, Quality = 80 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.AreEqual(80, Items[0].Quality); } }
public void BrieQualityGoesUpMultipleTimes() { for (int numDaysToSimulate = 0; numDaysToSimulate < 30; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "Aged Brie", SellIn = 100, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.AreEqual(10 + numDaysToSimulate, Items[0].Quality); } }
public void BrieQualityGoesUpTwiceAsFastPastSellInDate() { for (int numDaysToSimulate = 0; numDaysToSimulate < 10; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "Aged Brie", SellIn = 0, Quality = 10 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.AreEqual(10 + (2 * numDaysToSimulate), Items[0].Quality); } }
public void BrieQualityNeverAbove50() { for (int numDaysToSimulate = 0; numDaysToSimulate < 30; numDaysToSimulate++) { IList <Item> Items = new List <Item> { new Item { Name = "Aged Brie", SellIn = 15, Quality = 40 } }; QualityUpdater qualityUpdater = QualityFactory.GetQualityManager(Items[0]); for (int j = 0; j < numDaysToSimulate; j++) { qualityUpdater.UpdateItemQuality(Items[0]); } Assert.LessOrEqual(Items[0].Quality, 50); } }
// private methods #region UpdateQuality(Item item) /** * Updates quality and SellIn of a given item. */ private Item UpdateQuality(Item item) { QualityUpdater qualityUpdater = NameParser.GetQualityUpdaterForItem(item.Name); return(qualityUpdater.UpdateQuality(item)); }