Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment Finished #65

Open
wants to merge 1 commit into
base: testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/fi/oulu/tol/sqat/GildedRose.class
Binary file not shown.
Binary file modified bin/fi/oulu/tol/sqat/Item.class
Binary file not shown.
Binary file modified bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class
Binary file not shown.
192 changes: 191 additions & 1 deletion src/fi/oulu/tol/sqat/tests/GildedRoseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,199 @@ public void testUpdateEndOfDay_AgedBrie_Quality_10_11() {
Item itemBrie = items.get(0);
assertEquals(11, itemBrie.getQuality());
}

@Test
public void testUpdateEndOfDay_BackStagePassesQualityIncreasesBy2() {
// Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20) );

// Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();//10
store.updateEndOfDay();
store.updateEndOfDay();

// Assert
List<Item> items = store.getItems();
Item itemPass = items.get(0);
assertEquals(29, itemPass.getQuality());
}

@Test
public void testUpdateEndOfDay_BackStagePassesQualityIncreasesBy3() {
// Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20) );

// Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();//10
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();//5
store.updateEndOfDay();

// Assert
List<Item> items = store.getItems();
Item itemPass = items.get(0);
assertEquals(38, itemPass.getQuality());
}

@Test
public void testUpdateEndOfDay_BackStagePassesDropTo0() {
// Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20) );

// Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();//10
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();//5
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();//0
store.updateEndOfDay();

// Assert
List<Item> items = store.getItems();
Item itemPass = items.get(0);
assertEquals(0, itemPass.getQuality());
}

@Test
public void testUpdateEndOfDay() {
fail("Test not implemented");
//Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Conjured Mana Cake", 3, 6));

//Act
store.updateEndOfDay();

//Assert
List<Item> items = store.getItems();
Item itemCake = items.get(0);
assertEquals(5, itemCake.getQuality());
assertEquals(2, itemCake.getSellIn());
}

@Test
public void testUpdateEndOfDay_SulfurasQualityStaysAt80() {
//Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Sulfuras, Hand of Ragnaros", 0, 80));

//Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();

//Assert
List<Item> items = store.getItems();
Item itemSulfuras = items.get(0);
assertEquals(80, itemSulfuras.getQuality());
}

@Test
public void testUpdateEndOfDay_AgedBrieQualityNotOver50() {
//Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Aged Brie", 2, 50));

//Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();

//Assert
List<Item> items = store.getItems();
Item itemAgedBrie = items.get(0);
assertEquals(50, itemAgedBrie.getQuality());
}

@Test
public void testUpdateEndOfDay_5DexterityVestQualityDecreases() {
//Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("+5 Dexterity Vest", 10, 20));

//Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();

//Assert
List<Item> items = store.getItems();
Item item5DexterityVest = items.get(0);
assertEquals(17, item5DexterityVest.getQuality());
}

@Test
public void testUpdateEndOfDay_5DexterityVestSellInDecreases() {
//Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("+5 Dexterity Vest", 10, 20));

//Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();

//Assert
List<Item> items = store.getItems();
Item item5DexterityVest = items.get(0);
assertEquals(7, item5DexterityVest.getSellIn());
}

@Test
public void testUpdateEndOfDay_5DexterityVestQualityDecreasesTwiceAsFast() {
//Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("+5 Dexterity Vest", 0, 10));

//Act
store.updateEndOfDay();

//Assert
List<Item> items = store.getItems();
Item item5DexterityVest = items.get(0);
assertEquals(8, item5DexterityVest.getQuality());
}

@Test
public void testUpdateEndOfDay_ConjuredManaCakeQualityCantBeNegative() {
//Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Conjured Mana Cake", 3, 6));

//Act
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();

//Assert
List<Item> items = store.getItems();
Item itemConjuredManaCake = items.get(0);
assertEquals(0, itemConjuredManaCake.getQuality());
}
}