Skip to content

Instantly share code, notes, and snippets.

@JohanneA
Created November 22, 2021 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohanneA/70d06121e507a0e94b436bad2ba0eb82 to your computer and use it in GitHub Desktop.
Save JohanneA/70d06121e507a0e94b436bad2ba0eb82 to your computer and use it in GitHub Desktop.
Kotlin test DSL
fun getShipmentWithOneBox(): ShipmentBuilder {
return buildShipment {
id = 1L
buildBoxes {
id = 1L
buildProduct {
id = 1L
name = "Pink Fussy Jacket"
}
}
}
}
@Test
fun `shipment should have one box with snowboard in it`() {
val shipment = getShipmentWithOneBox().override {
overrideBox(1L) {
overrideProduct(1L) {
name = "Custom Snowboard"
}
}
}.build()
val firstBoxContent = shipment.boxes.first().contents.first()
assertThat(firstBoxContent.name).isEqualTo("Custom Snowboard")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment