Created
September 22, 2022 15:59
-
-
Save GeePawHill/e37fac2a11604801a617061b77a03f6f to your computer and use it in GitHub Desktop.
Third Version of Test Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `sulfuras never changes`() { | |
assertBeforeAndAfter(SULFURUS_NAME, Int.MAX_VALUE, 80, Int.MAX_VALUE,80) | |
} | |
@Test | |
fun `sulfuras never changes even with weird values`() { | |
// NOTE: Gilded rose does not enforce quality or sellin for sulfuras | |
assertBeforeAndAfter(SULFURUS_NAME,-1,-3,-1,-3) | |
} | |
@Test | |
fun `generic salable items lose quality by 1`() { | |
assertBeforeAndAfter(GENERIC_NAME,10,5,9,4) | |
} | |
fun assertBeforeAndAfter(beforeName:String,beforeSellin:Int,beforeQuality:Int,afterSellin:Int,afterQuality:Int) { | |
updateQuality(Item(beforeName,beforeSellin,beforeQuality)).apply { | |
assertThat(name).isEqualTo(beforeName) | |
assertThat(sellIn).isEqualTo(afterSellin) | |
assertThat(quality).isEqualTo(afterQuality) | |
} | |
} | |
fun updateQuality(item:Item):Item { | |
val items = arrayOf(item) | |
val app = GildedRose(items) | |
app.updateQuality() | |
return app.items[0] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment