2020-08-31 22:13:03 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace csharpcore
|
|
|
|
{
|
|
|
|
// "Conjured" items degrade in Quality twice as fast as normal items
|
|
|
|
public class ConjuredTest
|
|
|
|
{
|
|
|
|
private readonly List<Item> _items;
|
|
|
|
private GildedRose _rose;
|
|
|
|
|
|
|
|
public ConjuredTest()
|
|
|
|
{
|
|
|
|
_items = new List<Item>();
|
|
|
|
_rose =new GildedRose(_items);
|
|
|
|
}
|
|
|
|
|
2020-08-31 22:26:21 +00:00
|
|
|
[Theory]
|
|
|
|
[InlineData(3, 2, 1)]
|
|
|
|
[InlineData(5, 1, 3)]
|
|
|
|
[InlineData(5, 0, 1)]
|
|
|
|
public void ShouldDecreaseInQualityTwiceAsFastAsNormalItems(int inQuality, int sellInDays, int expectedQuality)
|
2020-08-31 22:13:03 +00:00
|
|
|
{
|
2020-08-31 22:26:21 +00:00
|
|
|
var item = GenerateItem(inQuality, sellInDays);
|
2020-08-31 22:13:03 +00:00
|
|
|
_items.Add(item);
|
|
|
|
|
|
|
|
_rose.UpdateQuality();
|
2020-08-31 22:26:21 +00:00
|
|
|
Assert.Equal(sellInDays - 1, item.SellIn);
|
|
|
|
Assert.Equal(expectedQuality, item.Quality);
|
2020-08-31 22:13:03 +00:00
|
|
|
}
|
2020-08-31 22:26:21 +00:00
|
|
|
|
2020-08-31 22:13:03 +00:00
|
|
|
public Item GenerateItem(int quality, int sellInDays)
|
|
|
|
=> new Item {Name = "Conjured Mana Cake", Quality = quality, SellIn = sellInDays};
|
|
|
|
}
|
|
|
|
}
|