Skip to content

Commit 89ae8b7

Browse files
anarchuserxeruf
authored andcommitted
test(sdk): switch SlotDescriptor test to table driven approach
1 parent 742c408 commit 89ae8b7

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
package sc.shared
22

33
import com.thoughtworks.xstream.XStream
4+
import io.kotlintest.data.forall
45
import io.kotlintest.specs.StringSpec
56
import io.kotlintest.inspectors.forAll
67
import io.kotlintest.shouldBe
8+
import io.kotlintest.tables.row
79

810
class SlotDescriptorTest : StringSpec({
911
"convert XML" {
1012
val xstream = XStream().apply {
1113
setMode(XStream.NO_REFERENCES)
1214
autodetectAnnotations(true)
1315
}
14-
val descriptors = listOf(
15-
SlotDescriptor() to
16-
"""<slotDescriptor displayName="Unknown" canTimeout="true" shouldBePaused="true"/>""",
16+
forall(
17+
row(SlotDescriptor(),
18+
"""<slotDescriptor displayName="Unknown" canTimeout="true" shouldBePaused="true"/>"""),
1719

18-
SlotDescriptor("Display Name") to
19-
"""<slotDescriptor displayName="Display Name" canTimeout="true" shouldBePaused="true"/>""",
20+
row(SlotDescriptor("Display Name"),
21+
"""<slotDescriptor displayName="Display Name" canTimeout="true" shouldBePaused="true"/>"""),
2022

21-
SlotDescriptor("name", false) to
22-
"""<slotDescriptor displayName="name" canTimeout="false" shouldBePaused="true"/>""",
23+
row(SlotDescriptor("name", false),
24+
"""<slotDescriptor displayName="name" canTimeout="false" shouldBePaused="true"/>"""),
2325

24-
SlotDescriptor("another name", true, false) to
25-
"""<slotDescriptor displayName="another name" canTimeout="true" shouldBePaused="false"/>"""
26+
row(SlotDescriptor("another name", true, false),
27+
"""<slotDescriptor displayName="another name" canTimeout="true" shouldBePaused="false"/>""")
2628
)
27-
28-
descriptors.forAll {
29-
xstream.toXML(it.first) shouldBe it.second
30-
xstream.fromXML(it.second).toString() shouldBe it.first.toString()
29+
{ descriptor, xml ->
30+
xstream.toXML(descriptor) shouldBe xml
31+
xstream.fromXML(xml).toString() shouldBe descriptor.toString()
3132
}
3233
}
3334
})

0 commit comments

Comments
 (0)