Extract fixture and make it immutable

This commit is contained in:
Ovi Trif 2018-10-05 21:23:30 +02:00
parent 9eedb327ae
commit d187e00d1f
3 changed files with 27 additions and 21 deletions

View File

@ -1,21 +1,18 @@
package com.gildedrose
import com.gildedrose.core.TestUtils
import org.assertj.core.api.Java6Assertions.assertThat
import org.junit.Test
import java.util.*
class GildedRoseTest {
private val store = arrayOf(
Item("+5 Dexterity Vest", 10, 20), //
Item("Aged Brie", 2, 0), //
Item("Elixir of the Mongoose", 5, 7), //
Item("Sulfuras, Hand of Ragnaros", 0, 80), //
Item("Sulfuras, Hand of Ragnaros", -1, 80),
Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
Item("Backstage passes to a TAFKAL80ETC concert", 5, 49)
)
private lateinit var store: Array<Item>
@Before
fun setUp() {
store = TestUtils.fixture
}
@Test
fun givenUnknownItem_afterRandomNumberOfDays_shouldDecreaseSellInByNumberOfDays() {

View File

@ -3,6 +3,7 @@ package com.gildedrose.acceptance
import com.gildedrose.GildedRose
import com.gildedrose.Item
import com.gildedrose.core.TestToFileHandler
import com.gildedrose.core.TestUtils
import org.junit.Assert.assertEquals
import org.junit.Test
@ -12,17 +13,7 @@ class ThirtyDaysAcceptanceTests {
@Test
fun withInitialTextFixture_whenRunForThirtyDays_itShouldHaveSameOutputAsLegacyCode() {
val initialTextFixture = arrayOf(
Item("+5 Dexterity Vest", 10, 20), //
Item("Aged Brie", 2, 0), //
Item("Elixir of the Mongoose", 5, 7), //
Item("Sulfuras, Hand of Ragnaros", 0, 80), //
Item("Sulfuras, Hand of Ragnaros", -1, 80),
Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
// this conjured item does not work properly yet
Item("Conjured Mana Cake", 3, 6))
val initialTextFixture = TestUtils.fixture
val output = runWithItemsForDays(initialTextFixture, 30)

View File

@ -0,0 +1,18 @@
package com.gildedrose.core
import com.gildedrose.Item
object TestUtils {
val fixture
get() = arrayOf(
Item("+5 Dexterity Vest", 10, 20),
Item("Aged Brie", 2, 0),
Item("Elixir of the Mongoose", 5, 7),
Item("Sulfuras, Hand of Ragnaros", 0, 80),
Item("Sulfuras, Hand of Ragnaros", -1, 80),
Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
Item("Conjured Mana Cake", 3, 6))
}