generated from SmartOperatingBlock/kotlin-template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
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 implantable medical device concept
- Loading branch information
1 parent
2e83b47
commit f0d7785
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/test/kotlin/entity/medicaldevice/ImplantableMedicalDeviceTest.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,55 @@ | ||
/* | ||
* 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 ImplantableMedicalDeviceTest : StringSpec({ | ||
val implantableMedicalDevice = ImplantableMedicalDevice( | ||
ImplantableMedicalDeviceID("imd1"), | ||
ImplantableMedicalDeviceType.PACEMAKER, | ||
) | ||
val implantableMedicalDeviceUpdated = ImplantableMedicalDevice( | ||
ImplantableMedicalDeviceID("imd1"), | ||
ImplantableMedicalDeviceType.CATHETER, | ||
) | ||
val differentImplantableMedicalDevice = ImplantableMedicalDevice( | ||
ImplantableMedicalDeviceID("imd2"), | ||
ImplantableMedicalDeviceType.PACEMAKER, | ||
) | ||
|
||
"implantable medical device id should not be empty" { | ||
shouldThrow<IllegalArgumentException> { ImplantableMedicalDeviceID("") } | ||
} | ||
|
||
listOf( | ||
differentImplantableMedicalDevice, | ||
null, | ||
4, | ||
).forEach { | ||
"a implantable medical device should not be equal to other devices with different id, other classes or null" { | ||
implantableMedicalDevice shouldNotBe it | ||
} | ||
} | ||
|
||
"two implantable medical devices are equal only based on their id" { | ||
implantableMedicalDevice shouldBe implantableMedicalDeviceUpdated | ||
} | ||
|
||
"two equal implantable medical devices should have the same hashcode" { | ||
implantableMedicalDevice.hashCode() shouldBe implantableMedicalDeviceUpdated.hashCode() | ||
} | ||
|
||
"two different implantable medical devices should not have the same hashcode" { | ||
implantableMedicalDevice.hashCode() shouldNotBe differentImplantableMedicalDevice.hashCode() | ||
} | ||
}) |