Skip to content

Commit 57aa1f7

Browse files
test(zone): test zone concepts
1 parent ea7bff8 commit 57aa1f7

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2023. Smart Operating Block
3+
*
4+
* Use of this source code is governed by an MIT-style
5+
* license that can be found in the LICENSE file or at
6+
* https://opensource.org/licenses/MIT.
7+
*/
8+
9+
package entity.zone
10+
11+
import io.kotest.assertions.throwables.shouldThrow
12+
import io.kotest.core.spec.style.StringSpec
13+
import io.kotest.matchers.shouldBe
14+
import io.kotest.matchers.shouldNotBe
15+
16+
class ZoneTest : StringSpec({
17+
val zone = Zone(ZoneID("1"), "name", "description")
18+
val zoneUpdate = Zone(ZoneID("1"), "name", "updated description")
19+
val differentZone = Zone(ZoneID("2"), "name", "description")
20+
21+
"zone id should not be empty" {
22+
shouldThrow<IllegalArgumentException> { ZoneID("") }
23+
}
24+
25+
"zone name should not be empty" {
26+
shouldThrow<IllegalArgumentException> { Zone(ZoneID("1"), "", "description") }
27+
}
28+
29+
"zone description should not be empty" {
30+
shouldThrow<IllegalArgumentException> { Zone(ZoneID("1"), "name", "") }
31+
}
32+
33+
listOf(
34+
differentZone,
35+
null,
36+
4
37+
).forEach {
38+
"a zone should not be equal to other zones with different id, other classes or null" {
39+
zone shouldNotBe it
40+
}
41+
}
42+
43+
"two zones are equal only based on their id" {
44+
zone shouldBe zoneUpdate
45+
}
46+
47+
"two equal zones should have the same hashcode" {
48+
zone.hashCode() shouldBe zoneUpdate.hashCode()
49+
}
50+
51+
"two different zones should not have the same hashcode" {
52+
zone.hashCode() shouldNotBe differentZone.hashCode()
53+
}
54+
})

0 commit comments

Comments
 (0)