Skip to content

Commit

Permalink
test(room): test room concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGiulianelli committed Feb 23, 2023
1 parent 23421d6 commit bdb4ad5
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/kotlin/entity/zone/RoomTest.kt
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()
}
})

0 comments on commit bdb4ad5

Please sign in to comment.