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 #73

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.
125 changes: 123 additions & 2 deletions src/fi/oulu/tol/sqat/tests/GildedRoseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,128 @@ public void testUpdateEndOfDay_AgedBrie_Quality_10_11() {
}

@Test
public void testUpdateEndOfDay() {
fail("Test not implemented");
public void testUpdateEndOfDay_AgedBrieReallyOld() {
// Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Aged Brie", 2, 10) );

// Act
for(int i = 0; i < 60; i++){
store.updateEndOfDay();
}

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

@Test
public void testUpdateEndOfDay_CreateSulfurasWithFalseQuality() {
// Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Sulfuras, Hand of Ragnaros", 2, 10) );

// Act
store.updateEndOfDay();

// Assert. This assert would pass if there would be prevention of falsely created items.
List<Item> items = store.getItems();
Item itemSulfuras = items.get(0);
assertEquals("Created Sulfuras with false quality and run updateEndOfDay", 80, itemSulfuras.getQuality());
}

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

// Act
store.updateEndOfDay();

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

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

// Acts and Asserts
store.updateEndOfDay();
List<Item> items = store.getItems();
Item itemPass = items.get(0);
assertEquals(1, itemPass.getQuality());
store.updateEndOfDay();
assertEquals(2, itemPass.getQuality());
store.updateEndOfDay();
assertEquals(4, itemPass.getQuality());
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
assertEquals(15, itemPass.getQuality());
store.updateEndOfDay();
assertEquals(18, itemPass.getQuality());
store.updateEndOfDay();
store.updateEndOfDay();
store.updateEndOfDay();
assertEquals(27, itemPass.getQuality());
store.updateEndOfDay();
assertEquals(0, itemPass.getQuality());
}

@Test
public void testUpdateEndOfDay_RandomItemQuality() {
// Arrange
GildedRose store = new GildedRose();
store.addItem(new Item("Just some item", 2, 10) );

// Acts and Asserts
store.updateEndOfDay();
List<Item> items = store.getItems();
Item itemSome = items.get(0);
assertEquals(9, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(8, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(6, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(4, itemSome.getQuality());
store.updateEndOfDay();
store.updateEndOfDay();
assertEquals(0, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(0, itemSome.getQuality());
}

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

// Acts and Asserts
store.updateEndOfDay();
List<Item> items = store.getItems();
Item itemSome = items.get(0);
assertEquals(9, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(8, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(6, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(4, itemSome.getQuality());
store.updateEndOfDay();
store.updateEndOfDay();
assertEquals(0, itemSome.getQuality());
store.updateEndOfDay();
assertEquals(0, itemSome.getQuality());
}
}