package com.zipcodewilmington.gildedrose; import org.junit.Assert; import org.junit.Before; import org.junit.Test; public class InventoryTest { private String name; private int sellIn; private int quality; private Item[] items; private Inventory store; private Item brie; private Item ticket; private Item legend; private Item other; @Before public void setUp(){ ticket = new Item("Backstage passes to a TAFKAL80ETC concert", 0,0); brie = new Item ("Aged Brie", 0,50); legend = new Item("Sulfuras, Hand of Ragnaros",0,50); other = new Item("other", 5,5); items =new Item[]{ brie, ticket, legend, other}; store = new Inventory(items); } @Test public void sellInTest(){ int expected = 5; int actual = other.getSellIn(); Assert.assertEquals(expected, actual); } @Test public void nameTest (){ store.updateQuality(); String expected = "Aged Brie"; String actual = brie.getName(); Assert.assertEquals(expected,actual); } @Test public void agedBrieQualityTest (){ store.updateQuality(); int expected =50; int actual = brie.getQuality(); Assert.assertEquals(expected,actual); } @Test public void agedBrieSellInTest (){ store.updateQuality(); int expected = -1; int actual = brie.getSellIn(); Assert.assertEquals(expected,actual); } //expired test that @Test // when expired quality increases by 2 public void agedBrieSellInExpiredTest (){ brie.setQuality(48); store.updateQuality(); int expected = 50; int actual = brie.getQuality(); Assert.assertEquals(expected,actual); } @Test public void setSellInTest (){ brie.setSellIn(10); int expected = 10; int actual = brie.getSellIn(); Assert.assertEquals(expected,actual); } @Test public void setQualityTest (){ brie.setQuality(10); int expected = 10; int actual = brie.getQuality(); Assert.assertEquals(expected,actual); } @Test public void agedBrieSetSellInUpdateTest (){ brie.setSellIn(10); store.updateQuality(); int expected = 9; int actual = brie.getSellIn(); Assert.assertEquals(expected,actual); } @Test public void agedBrieSetSellInQualityTest (){ brie.setSellIn(5); brie.setQuality(45); store.updateQuality(); int expected = 46; int actual = brie.getQuality(); Assert.assertEquals(expected,actual); } @Test public void ticketQualityTest (){ store.updateQuality(); int expected =0; int actual = ticket.getQuality(); Assert.assertEquals(expected,actual); } @Test public void ticketSellInTest (){ store.updateQuality(); int expected = -1; int actual = ticket.getSellIn(); Assert.assertEquals(expected,actual); } @Test public void ticketExpiredQualitySellInTest (){ ticket.setQuality(5); store.updateQuality(); int expected = 0; int actual = ticket.getQuality(); Assert.assertEquals(expected,actual); } @Test public void ticketSetSellInUpdateTest (){ ticket.setSellIn(10); store.updateQuality(); int expected = 9; int actual = ticket.getSellIn(); Assert.assertEquals(expected,actual); } @Test public void ticketSetFarSellInUpdateTest (){ ticket.setSellIn(20); store.updateQuality(); int expected = 1; int actual = ticket.getQuality(); Assert.assertEquals(expected,actual); } @Test public void ticketSetSellInQualityTest (){ ticket.setSellIn(5); ticket.setQuality(35); store.updateQuality(); int expected = 38; int actual = ticket.getQuality(); Assert.assertEquals(expected,actual); } @Test public void legendQualityTest (){ store.updateQuality(); int expected = 50; int actual = legend.getQuality(); Assert.assertEquals(expected,actual); } @Test public void legendSetSellInUpdateTest (){ ticket.setSellIn(35); store.updateQuality(); int expected = 0; int actual = legend.getSellIn(); Assert.assertEquals(expected,actual); } @Test public void otherQualityTest (){ store.updateQuality(); int expected =4; int actual = other.getQuality(); Assert.assertEquals(expected,actual); } @Test public void otherNameTest (){ other.setName("Thing"); String expected ="Thing"; String actual = other.getName(); Assert.assertEquals(expected,actual); } @Test public void otherSetSellInUpdateTest (){ other.setSellIn(1); store.updateQuality(); int expected = 0; int actual = other.getSellIn(); Assert.assertEquals(expected,actual); } @Test public void otherSetSellInExpiredUpdateTest (){ other.setSellIn(0); store.updateQuality(); int expected = -1; int actual = other.getSellIn(); Assert.assertEquals(expected,actual); } @Test public void otherQualityExpiredUpdateTest (){ other.setSellIn(-1); store.updateQuality(); int expected = 3; int actual = other.getQuality(); Assert.assertEquals(expected,actual); } }