forked from ardalis/GildedRoseStarter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdateQualityShould.cs
135 lines (113 loc) · 4.88 KB
/
UpdateQualityShould.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System.Collections.Generic;
using System.Linq;
using GildedRoseKata.Items;
using Xunit;
namespace GildedRoseKata
{
public class UpdateQualityShould
{
private const int DefaultSellIn = 10;
private const int DefaultQuality = 20;
private static DefaultItem UpdateQuality(DefaultItem item)
{
var items = new List<DefaultItem> {item};
var gildedRose = new GildedRose(items);
gildedRose.UpdateQuality();
return items.First();
}
[Fact]
public void DoNothingGivenSulfuras()
{
var item = UpdateQuality(new LegendaryItem() {Name = "Sulfuras, Hand of Ragnaros", SellIn = DefaultSellIn, Quality = 80});
Assert.Equal(DefaultSellIn, item.SellIn);
Assert.Equal(80, item.Quality);
}
[Fact]
public void AllItemsDecreaseSellInValue()
{
var item = UpdateQuality(new StandardItem {Name = "Foo", SellIn = DefaultSellIn, Quality = DefaultQuality});
Assert.Equal(9, item.SellIn);
}
[Fact]
public void AllItemsDecreaseQualityValue()
{
var item = UpdateQuality(new StandardItem {Name = "Foo", SellIn = DefaultSellIn, Quality = DefaultQuality});
Assert.Equal(DefaultQuality - 1, item.Quality);
}
[Fact]
public void QualityValueShouldDecreaseTwiceAsFastIfSellInIsPasted()
{
var item = UpdateQuality(new StandardItem {Name = "Foo", SellIn = 0, Quality = DefaultQuality});
Assert.Equal(DefaultQuality - 2, item.Quality);
}
[Fact]
public void QualityValueShouldNeverBelowZero()
{
var item = UpdateQuality(new StandardItem {Name = "Foo", SellIn = DefaultSellIn, Quality = 0});
Assert.Equal(0, item.Quality);
}
[Fact]
public void IncreasesQualityGivenAgedBrie()
{
var item = UpdateQuality(new IncreaseItem {Name = "Aged Brie", SellIn = DefaultSellIn, Quality = DefaultQuality});
Assert.Equal(DefaultQuality + 1, item.Quality);
Assert.Equal(DefaultSellIn - 1, item.SellIn);
}
[Fact]
public void QualityShouldBeNeverMoreThanFifty()
{
var item = UpdateQuality(new IncreaseItem {Name = "Aged Brie", SellIn = DefaultSellIn, Quality = 50});
Assert.Equal(50, item.Quality);
Assert.Equal(DefaultSellIn - 1, item.SellIn);
}
[Fact]
public void QualityOfBackstagePassesOutsideOfTenDays()
{
var item = UpdateQuality(new ConcertItems {Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 11, Quality = DefaultQuality});
Assert.Equal(DefaultQuality + 1, item.Quality);
Assert.Equal(10, item.SellIn);
}
[Fact]
public void QualityOfBackstagePassesInsideOfTenDays()
{
var item = UpdateQuality(new ConcertItems {Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = DefaultSellIn, Quality = DefaultQuality});
Assert.Equal(DefaultQuality + 2, item.Quality);
Assert.Equal(DefaultSellIn - 1, item.SellIn);
}
[Fact]
public void QualityOfBackstagePassesInsideOfTenDaysShouldNeverBeMoreThenFifty()
{
var item = UpdateQuality(new ConcertItems {Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = DefaultSellIn, Quality = 49});
Assert.Equal(50, item.Quality);
Assert.Equal(DefaultSellIn - 1, item.SellIn);
}
[Fact]
public void QualityOfBackstagePassesInsideOfFiveDays()
{
var item = UpdateQuality(new ConcertItems {Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = DefaultQuality});
Assert.Equal(DefaultQuality + 3, item.Quality);
Assert.Equal(4, item.SellIn);
}
[Fact]
public void QualityOfBackstagePassesInsideOfFiveDaysShouldNeverBeMoreThenFifty()
{
var item = UpdateQuality(new ConcertItems {Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 49});
Assert.Equal(50, item.Quality);
Assert.Equal(4, item.SellIn);
}
[Fact]
public void QualityOfBackstagePassesAfterTheConcertDate()
{
var item = UpdateQuality(new ConcertItems {Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = DefaultQuality});
Assert.Equal(0, item.Quality);
Assert.Equal(-1, item.SellIn);
}
[Fact]
public void QualityOfConjuredItems()
{
var item = UpdateQuality(new StandardItem {Name = "Conjured Mana Cake", SellIn = DefaultSellIn, Quality = DefaultQuality});
Assert.Equal(DefaultQuality - 2, item.Quality);
Assert.Equal(DefaultSellIn - 1, item.SellIn);
}
}
}