using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Xunit; namespace csharpcore { public class SulfurasTest { private readonly List _items = new List(); private readonly GildedRose _rose; public SulfurasTest() => _rose = new GildedRose(_items); [Theory] [MemberData(nameof(SulfurasData))] public void ShouldNotDecreaseQuality(int sellInDays) { var item = GenerateItem(1, sellInDays); _rose.UpdateQuality(); Assert.Equal(1, item.Quality); Assert.Equal(sellInDays, item.SellIn); } private Item GenerateItem(int quality, int sellIn) { var item = new Item {Name = "Sulfuras, Hand of Ragnaros", Quality = quality, SellIn = sellIn}; _items.Clear(); _items.Add(item); return item; } private static Random rnd = new Random(); public static IEnumerable SulfurasData() => Enumerable .Range(0, 5) .Select(n => new object[] { n }) .Concat( Enumerable.Range(0, 3) .Select(_ => new object[] { rnd.Next() })); } }