-
Notifications
You must be signed in to change notification settings - Fork 0
/
GildedRoseTest.cs
149 lines (138 loc) · 5.68 KB
/
GildedRoseTest.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using NUnit.Framework;
using System.Collections.Generic;
namespace csharp
{
[TestFixture]
public class GildedRoseTest
{
[Test]
public void UpdateQuality_AnyItem_NotNegative()
{
IList<Item> Items = new List<Item>
{
new Item { Name = "Regular Item", SellIn = -1, Quality = 0 },
new Item { Name = "Regular Item", SellIn = 5, Quality = 0 }
};
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(0, Items[0].Quality);
Assert.AreEqual(0, Items[1].Quality);
}
[Test]
public void UpdateQuality_AnyItem_SellInDaysDecreases()
{
IList<Item> Items = new List<Item>
{
new Item { Name = "Regular Item", SellIn = 5, Quality = 10 },
new Item { Name = "Aged Brie", SellIn = 5, Quality = 10 },
new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 5, Quality = 70 },
new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 40 },
};
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(4, Items[0].SellIn);
Assert.AreEqual(4, Items[1].SellIn);
Assert.AreEqual(5, Items[2].SellIn);
Assert.AreEqual(4, Items[3].SellIn);
}
[Test]
public void UpdateQuality_RegularSellDateNotPassed_DegradesQuality()
{
IList<Item> Items = new List<Item> { new Item { Name = "Regular Item", SellIn = 6, Quality = 10 } };
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(9, Items[0].Quality);
}
[Test]
public void UpdateQuality_RegularSellDateHasPassed_DegradesDouble()
{
IList<Item> Items = new List<Item> { new Item { Name = "Regular Item", SellIn = -1, Quality = 10 } };
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(8, Items[0].Quality);
}
[Test]
public void UpdateQuality_ConjuredSellDateNotPassed_DegradesQuality()
{
IList<Item> Items = new List<Item> { new Item { Name = "Conjured Mana Cake", SellIn = 6, Quality = 10 } };
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(8, Items[0].Quality);
}
[Test]
public void UpdateQuality_ConjuredSellDateHasPassed_DegradesDouble()
{
IList<Item> Items = new List<Item> { new Item { Name = "Conjured Mana Cake", SellIn = -1, Quality = 10 } };
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(6, Items[0].Quality);
}
[Test]
public void UpdateQuality_AgedSellDateHasPassed_IncreasesQuality()
{
IList<Item> Items = new List<Item>
{
new Item { Name = "Aged Brie", SellIn = -1, Quality = 10 },
};
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(12, Items[0].Quality);
}
[Test]
public void UpdateQuality_AgedSellDateNotPassed_IncreasesQuality()
{
IList<Item> Items = new List<Item>
{
new Item { Name = "Aged Brie", SellIn = 3, Quality = 10 },
new Item { Name = "Aged Brie", SellIn = 5, Quality = 50}
};
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(11, Items[0].Quality);
Assert.AreEqual(50, Items[1].Quality);
}
[Test]
public void UpdateQuality_Sulfuras_Unchanged()
{
IList<Item> Items = new List<Item>
{
new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 10, Quality = 80 },
new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 70 },
};
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(80, Items[0].Quality);
Assert.AreEqual(10, Items[0].SellIn);
Assert.AreEqual(70, Items[1].Quality);
Assert.AreEqual(-1, Items[1].SellIn);
}
[Test]
public void UpdateQuality_BackstagePasses_ZeroAfterSellIn()
{
IList<Item> Items = new List<Item>
{
new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 10 },
};
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(0, Items[0].Quality);
}
[Test]
public void UpdateQuality_BackstagePasses_IncreasesQualityBeforeSellIn()
{
IList<Item> Items = new List<Item>
{
new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 12, Quality = 10 },
new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 10, Quality = 10 },
new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 10 },
new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 50 },
};
GildedRose app = new GildedRose(Items);
app.UpdateQuality();
Assert.AreEqual(11, Items[0].Quality);
Assert.AreEqual(12, Items[1].Quality);
Assert.AreEqual(13, Items[2].Quality);
Assert.AreEqual(50, Items[3].Quality);
}
}
}