Skip to content

Commit

Permalink
Update MoreTypesTest with more identifierString tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LZRS committed Sep 1, 2023
1 parent 0602ab3 commit f46b9e6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fun Type.identifierString(context: Context): String =
?: when (this) {
is Coding ->
arrayOf("${this.system.orEmpty()}${this.version.orEmpty()}", this.code.orEmpty())
.joinToString(if (this.hasSystem() && this.hasCode()) "|" else "")
.joinToString(if (this.hasSystem().or(this.hasVersion()) && this.hasCode()) "|" else "")
is Reference -> this.reference ?: displayString(context)
else -> displayString(context)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,57 @@ class MoreTypesTest {
}

@Test
fun `Coding should return identifierString containing system, version and code`() {
fun `should return identifier string for coding containing system, version and code`() {
val coding = Coding("fakeSystem", "fakeCode", "fakeDisplay").apply { version = "2.0" }
assertThat(coding.identifierString(context)).isEqualTo("fakeSystem2.0|fakeCode")
}

@Test
fun `Coding without system should return identifierString containing code`() {
fun `should return identifier string for coding containing system and version`() {
val coding =
Coding().apply {
system = "fakeSystem"
version = "2.0"
}
assertThat(coding.identifierString(context)).isEqualTo("fakeSystem2.0")
}

@Test
fun `should return identifier string for coding containing system and code`() {
val coding = Coding("fakeSystem", "fakeCode", "fakeDisplay")
assertThat(coding.identifierString(context)).isEqualTo("fakeSystem|fakeCode")
}

@Test
fun `should return identifier string for coding containing only system`() {
val coding = Coding().apply { system = "fakeSystem" }
assertThat(coding.identifierString(context)).isEqualTo("fakeSystem")
}

@Test
fun `should return identifier string for coding containing version and code`() {
val coding =
Coding().apply {
version = "2.0"
code = "fakeCode"
}
assertThat(coding.identifierString(context)).isEqualTo("2.0|fakeCode")
}

@Test
fun `should return identifier string for coding containing only version`() {
val coding = Coding().apply { version = "2.0" }
assertThat(coding.identifierString(context)).isEqualTo("2.0")
}

@Test
fun `should return identifier string for coding containing only code`() {
val coding = Coding().apply { code = "fakeCode" }
assertThat(coding.identifierString(context)).isEqualTo("fakeCode")
}

@Test
fun `Reference should return reference`() {
fun `should return identifier string for reference`() {
val reference = Reference().apply { reference = "fakeReference" }
assertThat(reference.identifierString(context)).isEqualTo("fakeReference")
}
Expand Down

0 comments on commit f46b9e6

Please sign in to comment.