generated from SmartOperatingBlock/kotlin-template-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for medical technology concept
- Loading branch information
1 parent
f6058ec
commit 314d843
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/test/kotlin/entity/medicaldevice/MedicalTechnologyTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
}) |