diff --git a/src/test/kotlin/entity/zone/RoomTest.kt b/src/test/kotlin/entity/zone/RoomTest.kt new file mode 100644 index 00000000..49669853 --- /dev/null +++ b/src/test/kotlin/entity/zone/RoomTest.kt @@ -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 { 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() + } +})