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

GildedRose Assignment Completed #61

Open
wants to merge 1 commit into
base: master
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
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/fi/
Binary file modified bin/fi/oulu/tol/sqat/GildedRose.class
Binary file not shown.
Binary file modified bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class
Binary file not shown.
8 changes: 6 additions & 2 deletions src/fi/oulu/tol/sqat/GildedRose.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class GildedRose {

private static List<Item> items = null;
public static List<Item> items = null;

/**
* @param args
Expand All @@ -22,7 +22,11 @@ public static void main(String[] args) {
items.add(new Item("Sulfuras, Hand of Ragnaros", 0, 80));
items.add(new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20));
items.add(new Item("Conjured Mana Cake", 3, 6));



System.out.println(items.get(1).getName());


updateQuality();
}

Expand Down
137 changes: 137 additions & 0 deletions src/fi/oulu/tol/sqat/tests/GildedRoseTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,149 @@
package fi.oulu.tol.sqat.tests;


import static org.junit.Assert.*;
import org.junit.Test;

import fi.oulu.tol.sqat.GildedRose;
import fi.oulu.tol.sqat.Item;

import java.util.ArrayList;
import java.util.List;

public class GildedRoseTest {



@Test
public void testTheTruth() {
assertTrue(true);
}

@Test
public void testUpdateQualityForAddingNewItem() {

GildedRose.items = new ArrayList<Item>();
GildedRose.items.add(new Item("A new Item", 3, 6));
GildedRose.updateQuality();

int quality = GildedRose.items.get(0).getQuality();

assertEquals("The test fails for A new Item", 5, quality);
}

@Test
public void testUpdateQualityForAgedBrie() {

GildedRose.items = new ArrayList<Item>();
GildedRose.items.add(new Item("Aged Grie", 2, 0));
GildedRose.updateQuality();

int sellIn = GildedRose.items.get(0).getSellIn();

assertEquals(3, sellIn);

}

@Test
public void testUpdateQualityForSulfuras() {

/*
* "Sulfuras", being a legendary item, never has to be sold or decreases in Quality
*/

GildedRose.items = new ArrayList<Item>();
GildedRose.items.add(new Item("Sulfuras, Hand of Ragnaros", 0, 80));
GildedRose.updateQuality();

int sellIn = GildedRose.items.get(0).getSellIn();

assertEquals(0, sellIn);

}

@Test
public void testUpdateQualityForHigher50Quality() {

/*
* The Quality of an item is never more than 50
*/

GildedRose.items = new ArrayList<Item>();
GildedRose.items.add(new Item("Sulfuras, Hand of Ragnaros", 0, 80));
GildedRose.updateQuality();

int qulity = GildedRose.items.get(0).getQuality();

boolean isQualityLessThan50 = false;

if(qulity < 50) {

isQualityLessThan50 = true;
}

assertTrue("Quality value is biger > 50 ",isQualityLessThan50);

}

@Test
public void testUpdataQualityForBackstagePassesQualitySellInLess10days() {

/*
* "Backstage passes", like aged brie, increases in Quality as it's 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
*/

GildedRose.items = new ArrayList<Item>();
GildedRose.items.add(new Item("Backstage passes to a TAFKAL80ETC concert", 10, 20));
GildedRose.updateQuality();

int qulity = GildedRose.items.get(0).getQuality();

assertEquals("Quality should be increased by 2 when there are 10 days or less", 22, qulity);


}

@Test
public void testUpdataQualityForBackstagePassesQualitySellInLess5days() {

/*
* "Backstage passes", like aged brie, increases in Quality as it's 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
*/

GildedRose.items = new ArrayList<Item>();
GildedRose.items.add(new Item("Backstage passes to a TAFKAL80ETC concert", 10, 20));
GildedRose.updateQuality();

int qulity = GildedRose.items.get(0).getQuality();

assertEquals("Quality should be increased by 2 when there are 10 days or less", 23, qulity);


}

@Test
public void testUpdataQualityForlessThanZero() {

/*
* The Quality of an item is never negative
*/

GildedRose.items = new ArrayList<Item>();
GildedRose.items.add(new Item("Backstage passes to a TAFKAL80ETC concert", 10, -5));
GildedRose.updateQuality();

int qulity = GildedRose.items.get(0).getQuality();


boolean isQualityGreaterThanZero = true;

if(qulity < 0) {
isQualityGreaterThanZero = false;
}
assertTrue("The Quality of an item is never negative", isQualityGreaterThanZero);
}
}