mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
[unit test] - At the end of each day our system lowers both values for every item
This commit is contained in:
parent
f322e6eb1b
commit
91e8ffd57e
27
Java/README.md
Normal file
27
Java/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
## Why refactoring ?
|
||||
- Ability to easily add new kind of items(like conjured)
|
||||
- However, without altering the Item class or Items property
|
||||
|
||||
## Requirements
|
||||
|
||||
- All items have a SellIn value which denotes the number of days we have to sell the item
|
||||
- All items have a Quality value which denotes how valuable the item is
|
||||
- At the end of each day our system lowers both values for every item
|
||||
|
||||
# unit tests
|
||||
-[x] At the end of each day our system lowers both values for every item
|
||||
-[ ] Once the sell by date has passed, Quality degrades twice as fast
|
||||
-[ ] The Quality of an item is never negative
|
||||
-[ ] "Aged Brie" actually increases in Quality the older it gets
|
||||
-[ ] The Quality of an item is never more than 50
|
||||
-[ ] "Sulfuras", being a legendary item, never has to be sold or decreases in Quality
|
||||
-[ ] "Backstage passes", like aged brie, increases in Quality as its SellIn value approaches;
|
||||
-[ ] Quality increases by 2 when there are 10 days or less and by 3 when there are 5 days or less but
|
||||
-[ ] Quality drops to 0 after the concert
|
||||
-[ ] an item can never have its Quality increase above 50, however "Sulfuras" is a legendary item and as such its Quality is 80 and it never alters.
|
||||
|
||||
## Technical Issues, with a balanced priority
|
||||
-[ ]
|
||||
|
||||
## Refactoring actions
|
||||
|
||||
@ -11,7 +11,17 @@ public class GildedRoseTest {
|
||||
Item[] items = new Item[] { new Item("foo", 0, 0) };
|
||||
GildedRose app = new GildedRose(items);
|
||||
app.updateQuality();
|
||||
assertEquals("fixme", app.items[0].name);
|
||||
assertEquals("foo", app.items[0].name);
|
||||
}
|
||||
|
||||
//At the end of each day our system lowers both values for every item
|
||||
@Test
|
||||
public void shouldLowerBothValues(){
|
||||
Item[] items = new Item[] { TestHelper.getItem("foobar", 1, 1) };
|
||||
GildedRose app = new GildedRose(items);
|
||||
app.updateQuality();
|
||||
assertEquals(0, app.items[0].quality);
|
||||
assertEquals(0, app.items[0].sellIn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
8
Java/src/test/java/com/gildedrose/TestHelper.java
Normal file
8
Java/src/test/java/com/gildedrose/TestHelper.java
Normal file
@ -0,0 +1,8 @@
|
||||
package com.gildedrose;
|
||||
|
||||
public class TestHelper {
|
||||
|
||||
static Item getItem(String name, Integer sellIn, Integer quality){
|
||||
return new Item(name, sellIn, quality);
|
||||
}
|
||||
}
|
||||
@ -5,16 +5,17 @@ public class TexttestFixture {
|
||||
System.out.println("OMGHAI!");
|
||||
|
||||
Item[] items = new Item[] {
|
||||
new Item("+5 Dexterity Vest", 10, 20), //
|
||||
new Item("Aged Brie", 2, 0), //
|
||||
new Item("Elixir of the Mongoose", 5, 7), //
|
||||
new Item("Sulfuras, Hand of Ragnaros", 0, 80), //
|
||||
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
|
||||
// this conjured item does not work properly yet
|
||||
new Item("Conjured Mana Cake", 3, 6) };
|
||||
new Item("+5 Dexterity Vest", 10, 20), //
|
||||
new Item("Aged Brie", 2, 0), //
|
||||
new Item("Elixir of the Mongoose", 5, 7), //
|
||||
new Item("Sulfuras, Hand of Ragnaros", 0, 80), //
|
||||
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
|
||||
// this conjured item does not work properly yet
|
||||
new Item("Conjured Mana Cake", 3, 6)
|
||||
};
|
||||
|
||||
GildedRose app = new GildedRose(items);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user