mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
Extract fixture and make it immutable
This commit is contained in:
parent
9eedb327ae
commit
d187e00d1f
@ -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() {
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
18
src/test/kotlin/com/gildedrose/core/TestUtils.kt
Normal file
18
src/test/kotlin/com/gildedrose/core/TestUtils.kt
Normal 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))
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user