public void BackstagePassTestDegradationBands() { var item = new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 15, Quality = 21 }; UpdateQuality(item); Assert.Equal(item.Quality, 22); UpdateQuality(item); // 23 UpdateQuality(item); // 24 UpdateQuality(item); // 25 UpdateQuality(item); // 26 UpdateQuality(item); // 28 UpdateQuality(item); // 30 UpdateQuality(item); // 32 Assert.Equal(item.Quality, 32); UpdateQuality(item); // 34 UpdateQuality(item); // 36 UpdateQuality(item); // 39 UpdateQuality(item); // 42 Assert.Equal(item.Quality, 42); UpdateQuality(item); // 45 UpdateQuality(item); // 48 UpdateQuality(item); // 50 Assert.Equal(item.Quality, 50); // should be no more than 50! UpdateQuality(item); // 50 UpdateQuality(item); // 0 Assert.Equal(item.Quality, 0); // quality drops to zero now date has passed }
private void ExpiredItemsUpdate(Item item) { item.SellIn--; if (item.SellIn < 0) { if (NormalItem.Contains(item.Name) && item.Quality > 0) { item.Quality--; } if (item.Name == ConjuredCake) { item.Quality -= 2; if (item.Quality < 0) { item.Quality = 0; } } if (item.Name == BackstagePass || item.Quality < 0) { item.Quality = 0; } if (item.Name == AgedBrie && item.Quality < MaxQuality) { item.Quality++; } } }
private void UpdateQuality(Item item) { if (ItemChecker.IncreasesOverTime(item.Name)) IncreaseQuality(item); else DecreaseQuality(item); }
private void IncreaseQuality(Item item) { if (ItemChecker.IsBackStagePass(item.Name)) UpdateBackStagePass(item); else item.Quality += UpdateCalculator.Increase(item); }
public void QualityCannotExceedMaximumQuality() { Item goldenSunWatch = new Item{Name = "Golden Pocket Sun Watch", SellIn = 14, Quality = MAX_QUALITY}; Store.Items.Add(goldenSunWatch); Store.UpdateQuality(); Assert.That(goldenSunWatch.Quality, Is.LessThanOrEqualTo(MAX_QUALITY)); }
public void AgedBrieTestIncreasesInQuality() { var item = new Item { Name = "Aged Brie", SellIn = 2, Quality = 0 }; UpdateQuality(item); Assert.Equal(item.Quality, 1); Assert.Equal(item.SellIn, 1); }
public void UpgradeReturnsNewItem() { var item = new Item { SellIn = 10, Quality = 10 }; var result = _itemUpgrade.Upgrade(item); Assert.That(item, Is.Not.SameAs(result)); }
public void UpdateQuality(Item item) { if (item.Quality > 0) { item.Quality -= 2; } }
private void UpdateBackStagePass(Item item) { if (ItemChecker.BackStagePassExpired(item)) item.Quality = 0; else item.Quality += UpdateCalculator.BackStagePassIncrease(item); }
public void ConjuredItemsDegradeTwiceAsFast() { var item = new Item() { Name = CONJURED_MANA_CAKE, SellIn = 10, Quality = 10 }; item = UpdateItemQuality(item); Assert.That(item.Quality, Is.EqualTo(8)); }
public virtual void UpdateInventory(Item item) { AdjustSellInDays(item); AdjustQuality(item); if (item.SellIn < 0) AdjustQuality(item); }
public void AgedBrieIncreaseQualityAtTwiceTheRate() { var item = new Item() { Name = AGED_BRIE, SellIn = 0, Quality = 10 }; item = UpdateItemQuality(item); Assert.That(item.Quality, Is.EqualTo(12)); }
public static Item UpdateQuality(Item item) { var program = new Program {Items = new List<Item> {item}}; program.UpdateQuality(); return item; }
private void DecreaseQuality(Item item) { var decrease = UpdateCalculator.Decrease(item, ItemChecker.IsConjured(item.Name)); if (item.Quality - decrease >= 0) item.Quality -= decrease; }
public void BackstagePassesIncreaseInQuality() { var item = new Item() { Name = BACKSTAGE_PASSES, SellIn = 20, Quality = 10 }; item = UpdateItemQuality(item); Assert.That(item.SellIn, Is.EqualTo(19)); Assert.That(item.Quality, Is.EqualTo(11)); }
public void BackstagePassesIncreaseInAtTrippleRate() { var item = new Item() { Name = BACKSTAGE_PASSES, SellIn = 5, Quality = 10 }; item = UpdateItemQuality(item); Assert.That(item.SellIn, Is.EqualTo(4)); Assert.That(item.Quality, Is.EqualTo(13)); }
public void BackstagePassesExpire() { var item = new Item() { Name = BACKSTAGE_PASSES, SellIn = 0, Quality = 10 }; item = UpdateItemQuality(item); Assert.That(item.SellIn, Is.EqualTo(-1)); Assert.That(item.Quality, Is.EqualTo(0)); }
public void AgedBrieTestNoMoreThan50() { var item = new Item { Name = "Aged Brie", SellIn = 2, Quality = 48 }; UpdateQuality(item); UpdateQuality(item); UpdateQuality(item); Assert.Equal(item.Quality, 50); }
public void QualityCanNeverBeDecreasedBelowMinimumQuality() { Item deOideLederhosn = new Item { Name = "Lederhose", SellIn = 1000, Quality = MIN_QUALITY }; Store.Items.Add(deOideLederhosn); Store.UpdateQuality(); Assert.That(deOideLederhosn.Quality, Is.GreaterThanOrEqualTo(MIN_QUALITY)); }
public void when_updating_a_normal_item_past_its_sellby_date_should_degrade_two_quality() { var item = new Item { Name = "Item", Quality = 10, SellIn = 0 }; var program = CreateProgram(item); program.UpdateQuality(); Assert.That(item.Quality, Is.EqualTo(8)); }
public void when_updating_a_conjured_item_should_degrade_the_quality_twice_as_fast() { var item = new Item { Name = "Conjured Cloak", Quality = 30, SellIn = 5 }; var program = CreateProgram(item); program.UpdateQuality(); Assert.That(item.Quality, Is.EqualTo(28)); }
public void when_updating_aged_brie_with_50_quality_should_stay_at_50_quality() { var item = new Item { Name = "Aged Brie", Quality = 50, SellIn = 5 }; var program = CreateProgram(item); program.UpdateQuality(); Assert.That(item.Quality, Is.EqualTo(50)); }
public void when_updating_aged_brie_should_appreciate_one_quality() { var item = new Item { Name = "Aged Brie", Quality = 10, SellIn = 10 }; var program = CreateProgram(item); program.UpdateQuality(); Assert.That(item.Quality, Is.EqualTo(11)); }
public void CloneItem() { var item = new Item {SellIn = 10, Quality = 10}; var result = _itemUpgrade.Clone(item); Assert.That(item, Is.Not.SameAs(result)); Assert.That(item.Name, Is.EqualTo(result.Name)); Assert.That(item.SellIn, Is.EqualTo(result.SellIn)); Assert.That(item.Quality, Is.EqualTo(result.Quality)); }
private Item UpdateItemAsConjured(Item item) { item.Quality -= 2; if (item.Quality < 0) item.Quality = 0; item.SellIn -= 1; return item; }
private int CalculateDecrease(Item item) { var amountToDecreaseBy = item.SellIn < 1 ? 2 : 1; if (IsConjured(item.Name)) { amountToDecreaseBy *= 2; } return amountToDecreaseBy; }
private void DecreaseQuality(Item item) { var amountToDecreaseBy = CalculateDecrease(item); item.Quality -= amountToDecreaseBy; if (item.Quality < 0) { item.Quality = 0; } }
public void QuailityCanNeverBeMoreThanFifty() { var item = new Item { Name = "Aged Brie", SellIn = 2, Quality = 50 }; var subject = new Program { Items = new List<Item> { item } }; subject.UpdateQuality(); Assert.That(item.Quality, Is.EqualTo(50)); }
public void QuailityDegradesByTwoWhenPastTheSellinPeriod() { var item = new Item { Name = "+5 Dexterity Vest", Quality = 20, SellIn = 0 }; var subject = new Program { Items = new List<Item> { item } }; subject.UpdateQuality(); Assert.That(item.Quality, Is.EqualTo(18)); }
public void QuailityOfAnItemIsNeverNegative() { var item = new Item { Name = "+5 Dexterity Vest", Quality = 0, SellIn = 0 }; var subject = new Program { Items = new List<Item> { item } }; subject.UpdateQuality(); Assert.That(item.Quality, Is.EqualTo(0)); }