gilded-rose-dotnet-core/test/SulfurasTest.cs

42 lines
1.2 KiB
C#
Raw Permalink Normal View History

2020-08-31 19:36:58 +00:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Xunit;
namespace csharpcore
{
public class SulfurasTest
{
private readonly List<Item> _items = new List<Item>();
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<object[]> SulfurasData() => Enumerable
.Range(0, 5)
.Select(n => new object[] { n })
.Concat(
Enumerable.Range(0, 3)
.Select(_ => new object[] { rnd.Next() }));
}
}