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.
- Loading branch information
1 parent
23421d6
commit bdb4ad5
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
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,46 @@ | ||
/* | ||
* 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.zone | ||
|
||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.shouldNotBe | ||
|
||
class RoomTest : StringSpec({ | ||
val room = Room(RoomID("r1"), RoomType.OPERATING_ROOM, ZoneID("z1")) | ||
val roomUpdated = Room(RoomID("r1"), RoomType.OPERATING_ROOM, ZoneID("z1"), name = "name updated") | ||
val differentRoom = Room(RoomID("r2"), RoomType.PRE_OPERATING_ROOM, ZoneID("z1")) | ||
|
||
"room id should not be empty" { | ||
shouldThrow<IllegalArgumentException> { RoomID("") } | ||
} | ||
|
||
listOf( | ||
differentRoom, | ||
null, | ||
4 | ||
).forEach { | ||
"a room should not be equal to other rooms with different id, other classes or null" { | ||
room shouldNotBe it | ||
} | ||
} | ||
|
||
"two rooms are equal only based on their id" { | ||
room shouldBe roomUpdated | ||
} | ||
|
||
"two equal rooms should have the same hashcode" { | ||
room.hashCode() shouldBe roomUpdated.hashCode() | ||
} | ||
|
||
"two different rooms should not have the same hashcode" { | ||
room.hashCode() shouldNotBe differentRoom.hashCode() | ||
} | ||
}) |