mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
Add C# unit tests, use XUnit instead of NUnIt, add string consts.
This commit is contained in:
parent
78ee77bed7
commit
4db623c55c
373
csharp/ApprovalTest.ThirtyDays.approved.txt
Normal file
373
csharp/ApprovalTest.ThirtyDays.approved.txt
Normal file
@ -0,0 +1,373 @@
|
||||
OMGHAI!
|
||||
-------- day 0 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 10, 20
|
||||
Aged Brie, 2, 0
|
||||
Elixir of the Mongoose, 5, 7
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 15, 20
|
||||
Backstage passes to a Bob Marley concert, 10, 49
|
||||
Backstage passes to a Jungle Boys concert, 5, 49
|
||||
Conjured Mana Cake, 3, 6
|
||||
|
||||
-------- day 1 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 9, 19
|
||||
Aged Brie, 1, 1
|
||||
Elixir of the Mongoose, 4, 6
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 14, 21
|
||||
Backstage passes to a Bob Marley concert, 9, 50
|
||||
Backstage passes to a Jungle Boys concert, 4, 50
|
||||
Conjured Mana Cake, 2, 5
|
||||
|
||||
-------- day 2 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 8, 18
|
||||
Aged Brie, 0, 2
|
||||
Elixir of the Mongoose, 3, 5
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 13, 22
|
||||
Backstage passes to a Bob Marley concert, 8, 50
|
||||
Backstage passes to a Jungle Boys concert, 3, 50
|
||||
Conjured Mana Cake, 1, 4
|
||||
|
||||
-------- day 3 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 7, 17
|
||||
Aged Brie, -1, 4
|
||||
Elixir of the Mongoose, 2, 4
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 12, 23
|
||||
Backstage passes to a Bob Marley concert, 7, 50
|
||||
Backstage passes to a Jungle Boys concert, 2, 50
|
||||
Conjured Mana Cake, 0, 3
|
||||
|
||||
-------- day 4 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 6, 16
|
||||
Aged Brie, -2, 6
|
||||
Elixir of the Mongoose, 1, 3
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 11, 24
|
||||
Backstage passes to a Bob Marley concert, 6, 50
|
||||
Backstage passes to a Jungle Boys concert, 1, 50
|
||||
Conjured Mana Cake, -1, 1
|
||||
|
||||
-------- day 5 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 5, 15
|
||||
Aged Brie, -3, 8
|
||||
Elixir of the Mongoose, 0, 2
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 10, 25
|
||||
Backstage passes to a Bob Marley concert, 5, 50
|
||||
Backstage passes to a Jungle Boys concert, 0, 50
|
||||
Conjured Mana Cake, -2, 0
|
||||
|
||||
-------- day 6 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 4, 14
|
||||
Aged Brie, -4, 10
|
||||
Elixir of the Mongoose, -1, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 9, 27
|
||||
Backstage passes to a Bob Marley concert, 4, 50
|
||||
Backstage passes to a Jungle Boys concert, -1, 0
|
||||
Conjured Mana Cake, -3, 0
|
||||
|
||||
-------- day 7 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 3, 13
|
||||
Aged Brie, -5, 12
|
||||
Elixir of the Mongoose, -2, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 8, 29
|
||||
Backstage passes to a Bob Marley concert, 3, 50
|
||||
Backstage passes to a Jungle Boys concert, -2, 0
|
||||
Conjured Mana Cake, -4, 0
|
||||
|
||||
-------- day 8 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 2, 12
|
||||
Aged Brie, -6, 14
|
||||
Elixir of the Mongoose, -3, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 7, 31
|
||||
Backstage passes to a Bob Marley concert, 2, 50
|
||||
Backstage passes to a Jungle Boys concert, -3, 0
|
||||
Conjured Mana Cake, -5, 0
|
||||
|
||||
-------- day 9 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 1, 11
|
||||
Aged Brie, -7, 16
|
||||
Elixir of the Mongoose, -4, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 6, 33
|
||||
Backstage passes to a Bob Marley concert, 1, 50
|
||||
Backstage passes to a Jungle Boys concert, -4, 0
|
||||
Conjured Mana Cake, -6, 0
|
||||
|
||||
-------- day 10 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 0, 10
|
||||
Aged Brie, -8, 18
|
||||
Elixir of the Mongoose, -5, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 5, 35
|
||||
Backstage passes to a Bob Marley concert, 0, 50
|
||||
Backstage passes to a Jungle Boys concert, -5, 0
|
||||
Conjured Mana Cake, -7, 0
|
||||
|
||||
-------- day 11 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -1, 8
|
||||
Aged Brie, -9, 20
|
||||
Elixir of the Mongoose, -6, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 4, 38
|
||||
Backstage passes to a Bob Marley concert, -1, 0
|
||||
Backstage passes to a Jungle Boys concert, -6, 0
|
||||
Conjured Mana Cake, -8, 0
|
||||
|
||||
-------- day 12 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -2, 6
|
||||
Aged Brie, -10, 22
|
||||
Elixir of the Mongoose, -7, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 3, 41
|
||||
Backstage passes to a Bob Marley concert, -2, 0
|
||||
Backstage passes to a Jungle Boys concert, -7, 0
|
||||
Conjured Mana Cake, -9, 0
|
||||
|
||||
-------- day 13 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -3, 4
|
||||
Aged Brie, -11, 24
|
||||
Elixir of the Mongoose, -8, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 2, 44
|
||||
Backstage passes to a Bob Marley concert, -3, 0
|
||||
Backstage passes to a Jungle Boys concert, -8, 0
|
||||
Conjured Mana Cake, -10, 0
|
||||
|
||||
-------- day 14 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -4, 2
|
||||
Aged Brie, -12, 26
|
||||
Elixir of the Mongoose, -9, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 1, 47
|
||||
Backstage passes to a Bob Marley concert, -4, 0
|
||||
Backstage passes to a Jungle Boys concert, -9, 0
|
||||
Conjured Mana Cake, -11, 0
|
||||
|
||||
-------- day 15 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -5, 0
|
||||
Aged Brie, -13, 28
|
||||
Elixir of the Mongoose, -10, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 0, 50
|
||||
Backstage passes to a Bob Marley concert, -5, 0
|
||||
Backstage passes to a Jungle Boys concert, -10, 0
|
||||
Conjured Mana Cake, -12, 0
|
||||
|
||||
-------- day 16 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -6, 0
|
||||
Aged Brie, -14, 30
|
||||
Elixir of the Mongoose, -11, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -1, 0
|
||||
Backstage passes to a Bob Marley concert, -6, 0
|
||||
Backstage passes to a Jungle Boys concert, -11, 0
|
||||
Conjured Mana Cake, -13, 0
|
||||
|
||||
-------- day 17 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -7, 0
|
||||
Aged Brie, -15, 32
|
||||
Elixir of the Mongoose, -12, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -2, 0
|
||||
Backstage passes to a Bob Marley concert, -7, 0
|
||||
Backstage passes to a Jungle Boys concert, -12, 0
|
||||
Conjured Mana Cake, -14, 0
|
||||
|
||||
-------- day 18 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -8, 0
|
||||
Aged Brie, -16, 34
|
||||
Elixir of the Mongoose, -13, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -3, 0
|
||||
Backstage passes to a Bob Marley concert, -8, 0
|
||||
Backstage passes to a Jungle Boys concert, -13, 0
|
||||
Conjured Mana Cake, -15, 0
|
||||
|
||||
-------- day 19 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -9, 0
|
||||
Aged Brie, -17, 36
|
||||
Elixir of the Mongoose, -14, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -4, 0
|
||||
Backstage passes to a Bob Marley concert, -9, 0
|
||||
Backstage passes to a Jungle Boys concert, -14, 0
|
||||
Conjured Mana Cake, -16, 0
|
||||
|
||||
-------- day 20 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -10, 0
|
||||
Aged Brie, -18, 38
|
||||
Elixir of the Mongoose, -15, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -5, 0
|
||||
Backstage passes to a Bob Marley concert, -10, 0
|
||||
Backstage passes to a Jungle Boys concert, -15, 0
|
||||
Conjured Mana Cake, -17, 0
|
||||
|
||||
-------- day 21 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -11, 0
|
||||
Aged Brie, -19, 40
|
||||
Elixir of the Mongoose, -16, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -6, 0
|
||||
Backstage passes to a Bob Marley concert, -11, 0
|
||||
Backstage passes to a Jungle Boys concert, -16, 0
|
||||
Conjured Mana Cake, -18, 0
|
||||
|
||||
-------- day 22 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -12, 0
|
||||
Aged Brie, -20, 42
|
||||
Elixir of the Mongoose, -17, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -7, 0
|
||||
Backstage passes to a Bob Marley concert, -12, 0
|
||||
Backstage passes to a Jungle Boys concert, -17, 0
|
||||
Conjured Mana Cake, -19, 0
|
||||
|
||||
-------- day 23 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -13, 0
|
||||
Aged Brie, -21, 44
|
||||
Elixir of the Mongoose, -18, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -8, 0
|
||||
Backstage passes to a Bob Marley concert, -13, 0
|
||||
Backstage passes to a Jungle Boys concert, -18, 0
|
||||
Conjured Mana Cake, -20, 0
|
||||
|
||||
-------- day 24 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -14, 0
|
||||
Aged Brie, -22, 46
|
||||
Elixir of the Mongoose, -19, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -9, 0
|
||||
Backstage passes to a Bob Marley concert, -14, 0
|
||||
Backstage passes to a Jungle Boys concert, -19, 0
|
||||
Conjured Mana Cake, -21, 0
|
||||
|
||||
-------- day 25 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -15, 0
|
||||
Aged Brie, -23, 48
|
||||
Elixir of the Mongoose, -20, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -10, 0
|
||||
Backstage passes to a Bob Marley concert, -15, 0
|
||||
Backstage passes to a Jungle Boys concert, -20, 0
|
||||
Conjured Mana Cake, -22, 0
|
||||
|
||||
-------- day 26 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -16, 0
|
||||
Aged Brie, -24, 50
|
||||
Elixir of the Mongoose, -21, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -11, 0
|
||||
Backstage passes to a Bob Marley concert, -16, 0
|
||||
Backstage passes to a Jungle Boys concert, -21, 0
|
||||
Conjured Mana Cake, -23, 0
|
||||
|
||||
-------- day 27 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -17, 0
|
||||
Aged Brie, -25, 50
|
||||
Elixir of the Mongoose, -22, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -12, 0
|
||||
Backstage passes to a Bob Marley concert, -17, 0
|
||||
Backstage passes to a Jungle Boys concert, -22, 0
|
||||
Conjured Mana Cake, -24, 0
|
||||
|
||||
-------- day 28 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -18, 0
|
||||
Aged Brie, -26, 50
|
||||
Elixir of the Mongoose, -23, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -13, 0
|
||||
Backstage passes to a Bob Marley concert, -18, 0
|
||||
Backstage passes to a Jungle Boys concert, -23, 0
|
||||
Conjured Mana Cake, -25, 0
|
||||
|
||||
-------- day 29 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -19, 0
|
||||
Aged Brie, -27, 50
|
||||
Elixir of the Mongoose, -24, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -14, 0
|
||||
Backstage passes to a Bob Marley concert, -19, 0
|
||||
Backstage passes to a Jungle Boys concert, -24, 0
|
||||
Conjured Mana Cake, -26, 0
|
||||
|
||||
-------- day 30 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -20, 0
|
||||
Aged Brie, -28, 50
|
||||
Elixir of the Mongoose, -25, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -15, 0
|
||||
Backstage passes to a Bob Marley concert, -20, 0
|
||||
Backstage passes to a Jungle Boys concert, -25, 0
|
||||
Conjured Mana Cake, -27, 0
|
||||
|
||||
@ -14,7 +14,6 @@ namespace csharp
|
||||
[Test]
|
||||
public void ThirtyDays()
|
||||
{
|
||||
|
||||
StringBuilder fakeoutput = new StringBuilder();
|
||||
Console.SetOut(new StringWriter(fakeoutput));
|
||||
Console.SetIn(new StringReader("a\n"));
|
||||
|
||||
@ -14,7 +14,7 @@ namespace csharp
|
||||
{
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (Items[i].Name != "Aged Brie" && !Items[i].Name.Contains("Backstage passes"))
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace csharp
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
|
||||
if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (Items[i].Name.Contains("Backstage passes"))
|
||||
{
|
||||
if (Items[i].SellIn < 11)
|
||||
{
|
||||
@ -60,7 +60,7 @@ namespace csharp
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie")
|
||||
{
|
||||
if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (!Items[i].Name.Contains("Backstage passes"))
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
{
|
||||
|
||||
277
csharp/GildedRoseTests.cs
Normal file
277
csharp/GildedRoseTests.cs
Normal file
@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace csharp
|
||||
{
|
||||
[TestFixture]
|
||||
public class GildedRoseTests
|
||||
{
|
||||
Item _test_ordinary_item_01 = new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20};
|
||||
Item _test_aged_brie = new Item {Name = ItemNames.AgedBrie, SellIn = 2, Quality = 0};
|
||||
Item _test_ordinary_item_02 = new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7};
|
||||
Item _test_sulfuras_01 = new Item {Name = ItemNames.Sulfuras, SellIn = 0, Quality = 80};
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_item_name_is_not_altered()
|
||||
{
|
||||
// Arrange
|
||||
const String ItemName = "I am a hole, and I live in a mole.";
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemName, SellIn = 0, Quality = 0 } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(ItemName, items[0].Name);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest")]
|
||||
[TestCase(ItemNames.AgedBrie)]
|
||||
[TestCase("Elixir of the Mongoose")]
|
||||
[TestCase("some miscellaneous item")]
|
||||
[TestCase("Backstage passes to a TAFKAL80ETC concert")]
|
||||
[TestCase("Backstage passes to a Bob Marley concert")]
|
||||
[TestCase("Backstage passes to a Jungle Boys concert")]
|
||||
public void After_daily_update_SellIn_value_for_all_items_except_sulfuras_goes_down_by_one(string item_name)
|
||||
{
|
||||
// Arrange
|
||||
int initial_sellin_value = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = initial_sellin_value, Quality = 20 } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_sellin_value - 1, items[0].SellIn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_SellIn_value_for_sulfuras_remains_the_same()
|
||||
{
|
||||
// Arrange
|
||||
int initial_sellin_value = _test_sulfuras_01.SellIn;
|
||||
IList<Item> items = new List<Item> { _test_sulfuras_01 };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_sellin_value, items[0].SellIn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_Quality_value_for_sulfuras_remains_the_same()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = _test_sulfuras_01.Quality;
|
||||
IList<Item> items = new List<Item> { _test_sulfuras_01 };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_Quality_value_for_ordinary_items_goes_down_by_one()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value_01 = _test_ordinary_item_01.Quality;
|
||||
int initial_quality_value_02 = _test_ordinary_item_02.Quality;
|
||||
IList<Item> items = new List<Item> { _test_ordinary_item_01, _test_ordinary_item_02 };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value_01 - 1, items[0].Quality);
|
||||
Assert.AreEqual(initial_quality_value_02 - 1, items[1].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_Quality_value_for_aged_brie_goes_up_by_one()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = _test_aged_brie.Quality;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.AgedBrie, SellIn = 20, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value + 1, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Once_the_sell_by_date_has_passed_aged_brie_quality_goes_up_by_two_each_day()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = _test_aged_brie.Quality;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.AgedBrie, SellIn = -2, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value + 2, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Once_the_sell_by_date_has_passed_aged_brie_quality_will_not_go_above_50()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = 50;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.AgedBrie, SellIn = -2, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(items[0].Quality <= 50);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest")]
|
||||
[TestCase(ItemNames.AgedBrie)]
|
||||
[TestCase(ItemNames.Sulfuras)]
|
||||
[TestCase("Elixir of the Mongoose")]
|
||||
[TestCase("some miscellaneous item")]
|
||||
[TestCase("Backstage passes to a TAFKAL80ETC concert")]
|
||||
[TestCase("Backstage passes to a Bob Marley concert")]
|
||||
[TestCase("Backstage passes to a Jungle Boys concert")]
|
||||
public void The_quality_of_all_items_except_sulfuras_never_goes_above_50(string item_name)
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = 50;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = 10, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(items[0].Quality <= 50);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest", 10)]
|
||||
[TestCase(ItemNames.AgedBrie, 10)]
|
||||
[TestCase(ItemNames.Sulfuras, 10)]
|
||||
[TestCase("Elixir of the Mongoose", 10)]
|
||||
[TestCase("some miscellaneous item", 10)]
|
||||
[TestCase("some miscellaneous item", -2)]
|
||||
[TestCase("Backstage passes to a TAFKAL80ETC concert", 10)]
|
||||
[TestCase("Backstage passes to a Bob Marley concert", 10)]
|
||||
[TestCase("Backstage passes to a Jungle Boys concert", 10)]
|
||||
public void The_quality_of_an_item_is_never_negative(string item_name, int sellin)
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = 0;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = sellin, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(items[0].Quality >= 0);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest")]
|
||||
[TestCase("Elixir of the Mongoose")]
|
||||
[TestCase("some miscellaneous item")]
|
||||
public void Once_a_sell_by_date_is_passed_the_quality_of_ordinary_items_decreases_by_two_per_day(string item_name)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
const int PastSellByDate = 0;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = PastSellByDate, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue - 2, items[0].Quality);
|
||||
}
|
||||
|
||||
[TestCase(50)]
|
||||
[TestCase(30)]
|
||||
[TestCase(11)]
|
||||
public void After_daily_update_Quality_value_for_backstage_pass_goes_up_by_one_if_more_than_ten_days_to_go(int sellin)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = sellin, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue + 1, items[0].Quality);
|
||||
}
|
||||
|
||||
[TestCase(10)]
|
||||
[TestCase(9)]
|
||||
[TestCase(8)]
|
||||
[TestCase(7)]
|
||||
[TestCase(6)]
|
||||
public void quality_of_backstage_pass_increases_by_two_each_day_between_ten_days_and_six_days_before_concert_date(int sellin)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = sellin, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue + 2, items[0].Quality);
|
||||
}
|
||||
|
||||
[TestCase(5)]
|
||||
[TestCase(4)]
|
||||
[TestCase(3)]
|
||||
[TestCase(2)]
|
||||
[TestCase(1)]
|
||||
public void quality_of_backstage_pass_increases_by_three_each_day_five_days_or_less_before_concert_date(int sellin)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = sellin, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue + 3, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void quality_of_backstage_pass_drops_to_zero_after_concert_date()
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
const int PastConcertDate = 0;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = PastConcertDate, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(0, items[0].Quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
csharp/ItemNames.cs
Normal file
10
csharp/ItemNames.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace csharp
|
||||
{
|
||||
public static class ItemNames
|
||||
{
|
||||
public const string AgedBrie = "Aged Brie";
|
||||
public const string Sulfuras = "Sulfuras, Hand of Ragnaros";
|
||||
public const string BackstagePasses = "Backstage passes";
|
||||
public const string Conjured = "Conjured Mana Cake";
|
||||
}
|
||||
}
|
||||
@ -11,30 +11,15 @@ namespace csharp
|
||||
|
||||
IList<Item> Items = new List<Item>{
|
||||
new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
|
||||
new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
|
||||
new Item {Name = ItemNames.AgedBrie, SellIn = 2, Quality = 0},
|
||||
new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
|
||||
new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
|
||||
new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 15,
|
||||
Quality = 20
|
||||
},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 10,
|
||||
Quality = 49
|
||||
},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 5,
|
||||
Quality = 49
|
||||
},
|
||||
new Item {Name = ItemNames.Sulfuras, SellIn = 0, Quality = 80},
|
||||
new Item {Name = ItemNames.Sulfuras, SellIn = -1, Quality = 80},
|
||||
new Item {Name = $"{ItemNames.BackstagePasses} to a TAFKAL80ETC concert", SellIn = 15, Quality = 20},
|
||||
new Item {Name = $"{ItemNames.BackstagePasses} to a Bob Marley concert", SellIn = 10, Quality = 49},
|
||||
new Item {Name = $"{ItemNames.BackstagePasses} to a Jungle Boys concert", SellIn = 5, Quality = 49},
|
||||
// this conjured item does not work properly yet
|
||||
new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
|
||||
new Item {Name = ItemNames.Conjured, SellIn = 3, Quality = 6}
|
||||
};
|
||||
|
||||
var app = new GildedRose(Items);
|
||||
|
||||
@ -48,8 +48,8 @@
|
||||
<HintPath>packages\ApprovalUtilities.3.0.13\lib\net45\ApprovalUtilities.Net45.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -63,8 +63,9 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="ApprovalTest.cs" />
|
||||
<Compile Include="GildedRose.cs" />
|
||||
<Compile Include="GildedRoseTest.cs" />
|
||||
<Compile Include="GildedRoseTests.cs" />
|
||||
<Compile Include="Item.cs" />
|
||||
<Compile Include="ItemNames.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -2,6 +2,6 @@
|
||||
<packages>
|
||||
<package id="ApprovalTests" version="3.0.13" targetFramework="net452" />
|
||||
<package id="ApprovalUtilities" version="3.0.13" targetFramework="net452" />
|
||||
<package id="NUnit" version="3.9.0" targetFramework="net452" />
|
||||
<package id="NUnit" version="3.5.0" targetFramework="net452" />
|
||||
<package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net452" />
|
||||
</packages>
|
||||
373
csharpcore/ApprovalTest.ThirtyDays.approved.txt
Normal file
373
csharpcore/ApprovalTest.ThirtyDays.approved.txt
Normal file
@ -0,0 +1,373 @@
|
||||
OMGHAI!
|
||||
-------- day 0 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 10, 20
|
||||
Aged Brie, 2, 0
|
||||
Elixir of the Mongoose, 5, 7
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 15, 20
|
||||
Backstage passes to a Bob Marley concert, 10, 49
|
||||
Backstage passes to a Jungle Boys concert, 5, 49
|
||||
Conjured Mana Cake, 3, 6
|
||||
|
||||
-------- day 1 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 9, 19
|
||||
Aged Brie, 1, 1
|
||||
Elixir of the Mongoose, 4, 6
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 14, 21
|
||||
Backstage passes to a Bob Marley concert, 9, 50
|
||||
Backstage passes to a Jungle Boys concert, 4, 50
|
||||
Conjured Mana Cake, 2, 5
|
||||
|
||||
-------- day 2 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 8, 18
|
||||
Aged Brie, 0, 2
|
||||
Elixir of the Mongoose, 3, 5
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 13, 22
|
||||
Backstage passes to a Bob Marley concert, 8, 50
|
||||
Backstage passes to a Jungle Boys concert, 3, 50
|
||||
Conjured Mana Cake, 1, 4
|
||||
|
||||
-------- day 3 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 7, 17
|
||||
Aged Brie, -1, 4
|
||||
Elixir of the Mongoose, 2, 4
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 12, 23
|
||||
Backstage passes to a Bob Marley concert, 7, 50
|
||||
Backstage passes to a Jungle Boys concert, 2, 50
|
||||
Conjured Mana Cake, 0, 3
|
||||
|
||||
-------- day 4 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 6, 16
|
||||
Aged Brie, -2, 6
|
||||
Elixir of the Mongoose, 1, 3
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 11, 24
|
||||
Backstage passes to a Bob Marley concert, 6, 50
|
||||
Backstage passes to a Jungle Boys concert, 1, 50
|
||||
Conjured Mana Cake, -1, 1
|
||||
|
||||
-------- day 5 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 5, 15
|
||||
Aged Brie, -3, 8
|
||||
Elixir of the Mongoose, 0, 2
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 10, 25
|
||||
Backstage passes to a Bob Marley concert, 5, 50
|
||||
Backstage passes to a Jungle Boys concert, 0, 50
|
||||
Conjured Mana Cake, -2, 0
|
||||
|
||||
-------- day 6 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 4, 14
|
||||
Aged Brie, -4, 10
|
||||
Elixir of the Mongoose, -1, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 9, 27
|
||||
Backstage passes to a Bob Marley concert, 4, 50
|
||||
Backstage passes to a Jungle Boys concert, -1, 0
|
||||
Conjured Mana Cake, -3, 0
|
||||
|
||||
-------- day 7 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 3, 13
|
||||
Aged Brie, -5, 12
|
||||
Elixir of the Mongoose, -2, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 8, 29
|
||||
Backstage passes to a Bob Marley concert, 3, 50
|
||||
Backstage passes to a Jungle Boys concert, -2, 0
|
||||
Conjured Mana Cake, -4, 0
|
||||
|
||||
-------- day 8 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 2, 12
|
||||
Aged Brie, -6, 14
|
||||
Elixir of the Mongoose, -3, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 7, 31
|
||||
Backstage passes to a Bob Marley concert, 2, 50
|
||||
Backstage passes to a Jungle Boys concert, -3, 0
|
||||
Conjured Mana Cake, -5, 0
|
||||
|
||||
-------- day 9 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 1, 11
|
||||
Aged Brie, -7, 16
|
||||
Elixir of the Mongoose, -4, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 6, 33
|
||||
Backstage passes to a Bob Marley concert, 1, 50
|
||||
Backstage passes to a Jungle Boys concert, -4, 0
|
||||
Conjured Mana Cake, -6, 0
|
||||
|
||||
-------- day 10 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, 0, 10
|
||||
Aged Brie, -8, 18
|
||||
Elixir of the Mongoose, -5, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 5, 35
|
||||
Backstage passes to a Bob Marley concert, 0, 50
|
||||
Backstage passes to a Jungle Boys concert, -5, 0
|
||||
Conjured Mana Cake, -7, 0
|
||||
|
||||
-------- day 11 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -1, 8
|
||||
Aged Brie, -9, 20
|
||||
Elixir of the Mongoose, -6, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 4, 38
|
||||
Backstage passes to a Bob Marley concert, -1, 0
|
||||
Backstage passes to a Jungle Boys concert, -6, 0
|
||||
Conjured Mana Cake, -8, 0
|
||||
|
||||
-------- day 12 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -2, 6
|
||||
Aged Brie, -10, 22
|
||||
Elixir of the Mongoose, -7, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 3, 41
|
||||
Backstage passes to a Bob Marley concert, -2, 0
|
||||
Backstage passes to a Jungle Boys concert, -7, 0
|
||||
Conjured Mana Cake, -9, 0
|
||||
|
||||
-------- day 13 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -3, 4
|
||||
Aged Brie, -11, 24
|
||||
Elixir of the Mongoose, -8, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 2, 44
|
||||
Backstage passes to a Bob Marley concert, -3, 0
|
||||
Backstage passes to a Jungle Boys concert, -8, 0
|
||||
Conjured Mana Cake, -10, 0
|
||||
|
||||
-------- day 14 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -4, 2
|
||||
Aged Brie, -12, 26
|
||||
Elixir of the Mongoose, -9, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 1, 47
|
||||
Backstage passes to a Bob Marley concert, -4, 0
|
||||
Backstage passes to a Jungle Boys concert, -9, 0
|
||||
Conjured Mana Cake, -11, 0
|
||||
|
||||
-------- day 15 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -5, 0
|
||||
Aged Brie, -13, 28
|
||||
Elixir of the Mongoose, -10, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 0, 50
|
||||
Backstage passes to a Bob Marley concert, -5, 0
|
||||
Backstage passes to a Jungle Boys concert, -10, 0
|
||||
Conjured Mana Cake, -12, 0
|
||||
|
||||
-------- day 16 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -6, 0
|
||||
Aged Brie, -14, 30
|
||||
Elixir of the Mongoose, -11, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -1, 0
|
||||
Backstage passes to a Bob Marley concert, -6, 0
|
||||
Backstage passes to a Jungle Boys concert, -11, 0
|
||||
Conjured Mana Cake, -13, 0
|
||||
|
||||
-------- day 17 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -7, 0
|
||||
Aged Brie, -15, 32
|
||||
Elixir of the Mongoose, -12, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -2, 0
|
||||
Backstage passes to a Bob Marley concert, -7, 0
|
||||
Backstage passes to a Jungle Boys concert, -12, 0
|
||||
Conjured Mana Cake, -14, 0
|
||||
|
||||
-------- day 18 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -8, 0
|
||||
Aged Brie, -16, 34
|
||||
Elixir of the Mongoose, -13, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -3, 0
|
||||
Backstage passes to a Bob Marley concert, -8, 0
|
||||
Backstage passes to a Jungle Boys concert, -13, 0
|
||||
Conjured Mana Cake, -15, 0
|
||||
|
||||
-------- day 19 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -9, 0
|
||||
Aged Brie, -17, 36
|
||||
Elixir of the Mongoose, -14, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -4, 0
|
||||
Backstage passes to a Bob Marley concert, -9, 0
|
||||
Backstage passes to a Jungle Boys concert, -14, 0
|
||||
Conjured Mana Cake, -16, 0
|
||||
|
||||
-------- day 20 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -10, 0
|
||||
Aged Brie, -18, 38
|
||||
Elixir of the Mongoose, -15, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -5, 0
|
||||
Backstage passes to a Bob Marley concert, -10, 0
|
||||
Backstage passes to a Jungle Boys concert, -15, 0
|
||||
Conjured Mana Cake, -17, 0
|
||||
|
||||
-------- day 21 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -11, 0
|
||||
Aged Brie, -19, 40
|
||||
Elixir of the Mongoose, -16, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -6, 0
|
||||
Backstage passes to a Bob Marley concert, -11, 0
|
||||
Backstage passes to a Jungle Boys concert, -16, 0
|
||||
Conjured Mana Cake, -18, 0
|
||||
|
||||
-------- day 22 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -12, 0
|
||||
Aged Brie, -20, 42
|
||||
Elixir of the Mongoose, -17, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -7, 0
|
||||
Backstage passes to a Bob Marley concert, -12, 0
|
||||
Backstage passes to a Jungle Boys concert, -17, 0
|
||||
Conjured Mana Cake, -19, 0
|
||||
|
||||
-------- day 23 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -13, 0
|
||||
Aged Brie, -21, 44
|
||||
Elixir of the Mongoose, -18, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -8, 0
|
||||
Backstage passes to a Bob Marley concert, -13, 0
|
||||
Backstage passes to a Jungle Boys concert, -18, 0
|
||||
Conjured Mana Cake, -20, 0
|
||||
|
||||
-------- day 24 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -14, 0
|
||||
Aged Brie, -22, 46
|
||||
Elixir of the Mongoose, -19, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -9, 0
|
||||
Backstage passes to a Bob Marley concert, -14, 0
|
||||
Backstage passes to a Jungle Boys concert, -19, 0
|
||||
Conjured Mana Cake, -21, 0
|
||||
|
||||
-------- day 25 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -15, 0
|
||||
Aged Brie, -23, 48
|
||||
Elixir of the Mongoose, -20, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -10, 0
|
||||
Backstage passes to a Bob Marley concert, -15, 0
|
||||
Backstage passes to a Jungle Boys concert, -20, 0
|
||||
Conjured Mana Cake, -22, 0
|
||||
|
||||
-------- day 26 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -16, 0
|
||||
Aged Brie, -24, 50
|
||||
Elixir of the Mongoose, -21, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -11, 0
|
||||
Backstage passes to a Bob Marley concert, -16, 0
|
||||
Backstage passes to a Jungle Boys concert, -21, 0
|
||||
Conjured Mana Cake, -23, 0
|
||||
|
||||
-------- day 27 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -17, 0
|
||||
Aged Brie, -25, 50
|
||||
Elixir of the Mongoose, -22, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -12, 0
|
||||
Backstage passes to a Bob Marley concert, -17, 0
|
||||
Backstage passes to a Jungle Boys concert, -22, 0
|
||||
Conjured Mana Cake, -24, 0
|
||||
|
||||
-------- day 28 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -18, 0
|
||||
Aged Brie, -26, 50
|
||||
Elixir of the Mongoose, -23, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -13, 0
|
||||
Backstage passes to a Bob Marley concert, -18, 0
|
||||
Backstage passes to a Jungle Boys concert, -23, 0
|
||||
Conjured Mana Cake, -25, 0
|
||||
|
||||
-------- day 29 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -19, 0
|
||||
Aged Brie, -27, 50
|
||||
Elixir of the Mongoose, -24, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -14, 0
|
||||
Backstage passes to a Bob Marley concert, -19, 0
|
||||
Backstage passes to a Jungle Boys concert, -24, 0
|
||||
Conjured Mana Cake, -26, 0
|
||||
|
||||
-------- day 30 --------
|
||||
name, sellIn, quality
|
||||
+5 Dexterity Vest, -20, 0
|
||||
Aged Brie, -28, 50
|
||||
Elixir of the Mongoose, -25, 0
|
||||
Sulfuras, Hand of Ragnaros, 0, 80
|
||||
Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, -15, 0
|
||||
Backstage passes to a Bob Marley concert, -20, 0
|
||||
Backstage passes to a Jungle Boys concert, -25, 0
|
||||
Conjured Mana Cake, -27, 0
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
using Xunit;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using ApprovalTests;
|
||||
using ApprovalTests.Reporters;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace csharpcore
|
||||
{
|
||||
[UseReporter(typeof(DiffReporter))]
|
||||
[TestFixture]
|
||||
public class ApprovalTest
|
||||
{
|
||||
[Fact]
|
||||
[Test]
|
||||
public void ThirtyDays()
|
||||
{
|
||||
var fakeoutput = new StringBuilder();
|
||||
StringBuilder fakeoutput = new StringBuilder();
|
||||
Console.SetOut(new StringWriter(fakeoutput));
|
||||
Console.SetIn(new StringReader("a\n"));
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ namespace csharpcore
|
||||
{
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (Items[i].Name != "Aged Brie" && !Items[i].Name.Contains("Backstage passes"))
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace csharpcore
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
|
||||
if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (Items[i].Name.Contains("Backstage passes"))
|
||||
{
|
||||
if (Items[i].SellIn < 11)
|
||||
{
|
||||
@ -60,7 +60,7 @@ namespace csharpcore
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie")
|
||||
{
|
||||
if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (!Items[i].Name.Contains("Backstage passes"))
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
{
|
||||
|
||||
277
csharpcore/GildedRoseTests.cs
Normal file
277
csharpcore/GildedRoseTests.cs
Normal file
@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace csharpcore
|
||||
{
|
||||
[TestFixture]
|
||||
public class GildedRoseTests
|
||||
{
|
||||
Item _test_ordinary_item_01 = new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20};
|
||||
Item _test_aged_brie = new Item {Name = ItemNames.AgedBrie, SellIn = 2, Quality = 0};
|
||||
Item _test_ordinary_item_02 = new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7};
|
||||
Item _test_sulfuras_01 = new Item {Name = ItemNames.Sulfuras, SellIn = 0, Quality = 80};
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_item_name_is_not_altered()
|
||||
{
|
||||
// Arrange
|
||||
const String ItemName = "I am a hole, and I live in a mole.";
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemName, SellIn = 0, Quality = 0 } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(ItemName, items[0].Name);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest")]
|
||||
[TestCase(ItemNames.AgedBrie)]
|
||||
[TestCase("Elixir of the Mongoose")]
|
||||
[TestCase("some miscellaneous item")]
|
||||
[TestCase("Backstage passes to a TAFKAL80ETC concert")]
|
||||
[TestCase("Backstage passes to a Bob Marley concert")]
|
||||
[TestCase("Backstage passes to a Jungle Boys concert")]
|
||||
public void After_daily_update_SellIn_value_for_all_items_except_sulfuras_goes_down_by_one(string item_name)
|
||||
{
|
||||
// Arrange
|
||||
int initial_sellin_value = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = initial_sellin_value, Quality = 20 } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_sellin_value - 1, items[0].SellIn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_SellIn_value_for_sulfuras_remains_the_same()
|
||||
{
|
||||
// Arrange
|
||||
int initial_sellin_value = _test_sulfuras_01.SellIn;
|
||||
IList<Item> items = new List<Item> { _test_sulfuras_01 };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_sellin_value, items[0].SellIn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_Quality_value_for_sulfuras_remains_the_same()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = _test_sulfuras_01.Quality;
|
||||
IList<Item> items = new List<Item> { _test_sulfuras_01 };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_Quality_value_for_ordinary_items_goes_down_by_one()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value_01 = _test_ordinary_item_01.Quality;
|
||||
int initial_quality_value_02 = _test_ordinary_item_02.Quality;
|
||||
IList<Item> items = new List<Item> { _test_ordinary_item_01, _test_ordinary_item_02 };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value_01 - 1, items[0].Quality);
|
||||
Assert.AreEqual(initial_quality_value_02 - 1, items[1].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void After_daily_update_Quality_value_for_aged_brie_goes_up_by_one()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = _test_aged_brie.Quality;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.AgedBrie, SellIn = 20, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value + 1, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Once_the_sell_by_date_has_passed_aged_brie_quality_goes_up_by_two_each_day()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = _test_aged_brie.Quality;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.AgedBrie, SellIn = -2, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(initial_quality_value + 2, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Once_the_sell_by_date_has_passed_aged_brie_quality_will_not_go_above_50()
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = 50;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.AgedBrie, SellIn = -2, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(items[0].Quality <= 50);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest")]
|
||||
[TestCase(ItemNames.AgedBrie)]
|
||||
[TestCase(ItemNames.Sulfuras)]
|
||||
[TestCase("Elixir of the Mongoose")]
|
||||
[TestCase("some miscellaneous item")]
|
||||
[TestCase("Backstage passes to a TAFKAL80ETC concert")]
|
||||
[TestCase("Backstage passes to a Bob Marley concert")]
|
||||
[TestCase("Backstage passes to a Jungle Boys concert")]
|
||||
public void The_quality_of_all_items_except_sulfuras_never_goes_above_50(string item_name)
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = 50;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = 10, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(items[0].Quality <= 50);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest", 10)]
|
||||
[TestCase(ItemNames.AgedBrie, 10)]
|
||||
[TestCase(ItemNames.Sulfuras, 10)]
|
||||
[TestCase("Elixir of the Mongoose", 10)]
|
||||
[TestCase("some miscellaneous item", 10)]
|
||||
[TestCase("some miscellaneous item", -2)]
|
||||
[TestCase("Backstage passes to a TAFKAL80ETC concert", 10)]
|
||||
[TestCase("Backstage passes to a Bob Marley concert", 10)]
|
||||
[TestCase("Backstage passes to a Jungle Boys concert", 10)]
|
||||
public void The_quality_of_an_item_is_never_negative(string item_name, int sellin)
|
||||
{
|
||||
// Arrange
|
||||
int initial_quality_value = 0;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = sellin, Quality = initial_quality_value } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(items[0].Quality >= 0);
|
||||
}
|
||||
|
||||
[TestCase("+5 Dexterity Vest")]
|
||||
[TestCase("Elixir of the Mongoose")]
|
||||
[TestCase("some miscellaneous item")]
|
||||
public void Once_a_sell_by_date_is_passed_the_quality_of_ordinary_items_decreases_by_two_per_day(string item_name)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
const int PastSellByDate = 0;
|
||||
IList<Item> items = new List<Item> { new Item { Name = item_name, SellIn = PastSellByDate, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue - 2, items[0].Quality);
|
||||
}
|
||||
|
||||
[TestCase(50)]
|
||||
[TestCase(30)]
|
||||
[TestCase(11)]
|
||||
public void After_daily_update_Quality_value_for_backstage_pass_goes_up_by_one_if_more_than_ten_days_to_go(int sellin)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = sellin, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue + 1, items[0].Quality);
|
||||
}
|
||||
|
||||
[TestCase(10)]
|
||||
[TestCase(9)]
|
||||
[TestCase(8)]
|
||||
[TestCase(7)]
|
||||
[TestCase(6)]
|
||||
public void quality_of_backstage_pass_increases_by_two_each_day_between_ten_days_and_six_days_before_concert_date(int sellin)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = sellin, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue + 2, items[0].Quality);
|
||||
}
|
||||
|
||||
[TestCase(5)]
|
||||
[TestCase(4)]
|
||||
[TestCase(3)]
|
||||
[TestCase(2)]
|
||||
[TestCase(1)]
|
||||
public void quality_of_backstage_pass_increases_by_three_each_day_five_days_or_less_before_concert_date(int sellin)
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = sellin, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(InitialQualityValue + 3, items[0].Quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void quality_of_backstage_pass_drops_to_zero_after_concert_date()
|
||||
{
|
||||
// Arrange
|
||||
const int InitialQualityValue = 10;
|
||||
const int PastConcertDate = 0;
|
||||
IList<Item> items = new List<Item> { new Item { Name = ItemNames.BackstagePasses, SellIn = PastConcertDate, Quality = InitialQualityValue } };
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
// Act
|
||||
app.UpdateQuality();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(0, items[0].Quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,5 +5,10 @@
|
||||
public string Name { get; set; }
|
||||
public int SellIn { get; set; }
|
||||
public int Quality { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name + ", " + this.SellIn + ", " + this.Quality;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
csharpcore/ItemNames.cs
Normal file
10
csharpcore/ItemNames.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace csharpcore
|
||||
{
|
||||
public static class ItemNames
|
||||
{
|
||||
public const string AgedBrie = "Aged Brie";
|
||||
public const string Sulfuras = "Sulfuras, Hand of Ragnaros";
|
||||
public const string BackstagePasses = "Backstage passes";
|
||||
public const string Conjured = "Conjured Mana Cake";
|
||||
}
|
||||
}
|
||||
@ -11,30 +11,15 @@ namespace csharpcore
|
||||
|
||||
IList<Item> Items = new List<Item>{
|
||||
new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
|
||||
new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
|
||||
new Item {Name = ItemNames.AgedBrie, SellIn = 2, Quality = 0},
|
||||
new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
|
||||
new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
|
||||
new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 15,
|
||||
Quality = 20
|
||||
},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 10,
|
||||
Quality = 49
|
||||
},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 5,
|
||||
Quality = 49
|
||||
},
|
||||
// this conjured item does not work properly yet
|
||||
new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
|
||||
new Item {Name = ItemNames.Sulfuras, SellIn = 0, Quality = 80},
|
||||
new Item {Name = ItemNames.Sulfuras, SellIn = -1, Quality = 80},
|
||||
new Item {Name = $"{ItemNames.BackstagePasses} to a TAFKAL80ETC concert", SellIn = 15, Quality = 20},
|
||||
new Item {Name = $"{ItemNames.BackstagePasses} to a Bob Marley concert", SellIn = 10, Quality = 49},
|
||||
new Item {Name = $"{ItemNames.BackstagePasses} to a Jungle Boys concert", SellIn = 5, Quality = 49},
|
||||
// this conjured item does not work properly yet
|
||||
new Item {Name = ItemNames.Conjured, SellIn = 3, Quality = 6}
|
||||
};
|
||||
|
||||
var app = new GildedRose(Items);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<StartupObject>csharpcore.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -11,5 +11,7 @@
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
||||
<PackageReference Include="nunit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user