commonTest.XmlBuilderTest.kt Maven / Gradle / Ivy
import ua.vald_zx.simplexml.ksp.xml.tag
import kotlin.test.Test
import kotlin.test.assertEquals
class XmlBuilderTest {
private val prettyXml = """
1234
qwerty
Android
""".trimIndent()
private val lineXml =
"1234 qwerty Android "
@Test
fun buildPrettyXml() {
val xmlString = tag("Auth", pretty = true) {
tag("UserId", "1234")
tag("Auth") {
tag("Password", "qwerty")
tag("Auth") {
tag("Device", "Android")
}
}
}.render()
assertEquals(xmlString, prettyXml)
}
@Test
fun buildLineXml() {
val xmlString = tag("Auth") {
tag("UserId", "1234")
tag("Auth") {
attr("lang", "ru")
tag("Password", "qwerty")
tag("Auth") {
tag("Device", "Android")
}
}
}.render()
assertEquals(xmlString, lineXml)
}
@Test
fun buildTextXml() {
val xmlString = tag("Auth") {
attr("lang", "ru")
text("1234")
}.render()
assertEquals(xmlString, "1234 ")
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy