Skip to content

Commit

Permalink
test: add tests for medical technology concept
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGiulianelli committed May 10, 2023
1 parent f6058ec commit 314d843
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/test/kotlin/entity/medicaldevice/MedicalTechnologyTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2023. Smart Operating Block
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/

package entity.medicaldevice

import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe

class MedicalTechnologyTest : StringSpec({
val medicalTechnology = MedicalTechnology(
MedicalTechnologyID("m1"),
"endoscope",
type = MedicalTechnologyType.ENDOSCOPE,
)
val medicalTechnologyUpdated = MedicalTechnology(
MedicalTechnologyID("m1"),
"endoscope updated",
type = MedicalTechnologyType.ENDOSCOPE,
)
val differentMedicalTechnology = MedicalTechnology(
MedicalTechnologyID("m2"),
"endoscope",
type = MedicalTechnologyType.ENDOSCOPE,
)

"medical technology id should not be empty" {
shouldThrow<IllegalArgumentException> { MedicalTechnologyID("") }
}

listOf(
differentMedicalTechnology,
null,
4,
).forEach {
"a medical technology should not be equal to other technologies with different id, other classes or null" {
medicalTechnology shouldNotBe it
}
}

"two medical technologies are equal only based on their id" {
medicalTechnology shouldBe medicalTechnologyUpdated
}

"two equal medical technologies should have the same hashcode" {
medicalTechnology.hashCode() shouldBe medicalTechnologyUpdated.hashCode()
}

"two different medical technologies should not have the same hashcode" {
medicalTechnology.hashCode() shouldNotBe differentMedicalTechnology.hashCode()
}
})

0 comments on commit 314d843

Please sign in to comment.