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
|
package com.gildedrose
|
||||||
|
|
||||||
|
import com.gildedrose.core.TestUtils
|
||||||
import org.assertj.core.api.Java6Assertions.assertThat
|
import org.assertj.core.api.Java6Assertions.assertThat
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class GildedRoseTest {
|
class GildedRoseTest {
|
||||||
|
|
||||||
private val store = arrayOf(
|
private lateinit var store: Array<Item>
|
||||||
Item("+5 Dexterity Vest", 10, 20), //
|
|
||||||
Item("Aged Brie", 2, 0), //
|
@Before
|
||||||
Item("Elixir of the Mongoose", 5, 7), //
|
fun setUp() {
|
||||||
Item("Sulfuras, Hand of Ragnaros", 0, 80), //
|
store = TestUtils.fixture
|
||||||
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)
|
|
||||||
)
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun givenUnknownItem_afterRandomNumberOfDays_shouldDecreaseSellInByNumberOfDays() {
|
fun givenUnknownItem_afterRandomNumberOfDays_shouldDecreaseSellInByNumberOfDays() {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.gildedrose.acceptance
|
|||||||
import com.gildedrose.GildedRose
|
import com.gildedrose.GildedRose
|
||||||
import com.gildedrose.Item
|
import com.gildedrose.Item
|
||||||
import com.gildedrose.core.TestToFileHandler
|
import com.gildedrose.core.TestToFileHandler
|
||||||
|
import com.gildedrose.core.TestUtils
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
@ -12,17 +13,7 @@ class ThirtyDaysAcceptanceTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun withInitialTextFixture_whenRunForThirtyDays_itShouldHaveSameOutputAsLegacyCode() {
|
fun withInitialTextFixture_whenRunForThirtyDays_itShouldHaveSameOutputAsLegacyCode() {
|
||||||
val initialTextFixture = arrayOf(
|
val initialTextFixture = TestUtils.fixture
|
||||||
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 output = runWithItemsForDays(initialTextFixture, 30)
|
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