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

43 lines
1.4 KiB
C#
Raw Normal View History

2020-08-31 19:36:58 +00:00
using System.Collections.Generic;
using Xunit;
namespace csharpcore
{
public class AgedBrieTest
{
[Theory]
[MemberData(nameof(AgedBrieData))]
public void ShouldIncreaseQuality(int sellIn, int quality, int expectedQuality)
{
var item = new Item {Name = "Aged Brie", SellIn = sellIn, Quality = quality};
var app = new GildedRose(new List<Item> {item});
app.UpdateQuality();
Assert.Equal("Aged Brie", item.Name);
Assert.Equal(sellIn - 1, item.SellIn);
Assert.Equal(expectedQuality, item.Quality);
}
public static object[][] AgedBrieData => new[]
{
/* sellIn, quality, expectedQuality*/
new object[]{ 1, 1, 2 },
new object[]{ 0, 1, 3 },
new object[]{ -1, 1, 3 },
};
2020-08-31 22:13:03 +00:00
[Theory]
[InlineData(1, 0)]
[InlineData(-1, -2)]
public void ShouldNotIncreaseQualityMoreThan50(int startSellInDays, int expectedSellInDays)
2020-08-31 19:36:58 +00:00
{
2020-08-31 22:13:03 +00:00
var item = new Item {Name = "Aged Brie", SellIn = startSellInDays, Quality = 50};
2020-08-31 19:36:58 +00:00
var app = new GildedRose(new List<Item> {item});
app.UpdateQuality();
Assert.Equal("Aged Brie", item.Name);
2020-08-31 22:13:03 +00:00
Assert.Equal(expectedSellInDays, item.SellIn);
2020-08-31 19:36:58 +00:00
Assert.Equal(50, item.Quality);
}
}
}