[unit test] - At the end of each day our system lowers both values for every item

This commit is contained in:
Sallah Kokaina 2019-11-01 11:19:22 +01:00
parent f322e6eb1b
commit 91e8ffd57e
4 changed files with 57 additions and 11 deletions

27
Java/README.md Normal file
View 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

View File

@ -11,7 +11,17 @@ public class GildedRoseTest {
Item[] items = new Item[] { new Item("foo", 0, 0) }; Item[] items = new Item[] { new Item("foo", 0, 0) };
GildedRose app = new GildedRose(items); GildedRose app = new GildedRose(items);
app.updateQuality(); 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);
} }
} }

View 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);
}
}

View File

@ -14,7 +14,8 @@ public class TexttestFixture {
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
// this conjured item does not work properly yet // this conjured item does not work properly yet
new Item("Conjured Mana Cake", 3, 6) }; new Item("Conjured Mana Cake", 3, 6)
};
GildedRose app = new GildedRose(items); GildedRose app = new GildedRose(items);