42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
|
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() }));
|
||
|
}
|
||
|
}
|