Skip to content

Commit a8472d4

Browse files
committed
tp5 step 2
1 parent 1044293 commit a8472d4

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

tp5/src/test/kotlin/fmt/kotlin/fundamentals/BottleTest.kt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package fmt.kotlin.fundamentals
22

3+
import fmt.kotlin.fundamentals.WineColor.RED
4+
import fmt.kotlin.fundamentals.WineColor.WHITE
35
import org.junit.jupiter.api.Assertions.*
46
import org.junit.jupiter.api.Nested
57
import strikt.api.expectThat
@@ -14,38 +16,56 @@ class BottleTest {
1416
inner class Equality {
1517
@Test
1618
fun `should be equals if name and year are equals`() {
17-
val isEqual = Bottle("Coucheroy", 2005).isEqualTo(Bottle("Coucheroy", 2005))
19+
val isEqual = Bottle("Coucheroy", 2005, RED).isEqualTo(Bottle("Coucheroy", 2005, RED))
1820

1921
expectThat(isEqual).isTrue()
2022
}
2123

2224
@Test
2325
fun `should not be equals if year is different`() {
24-
val isEqual = Bottle("Coucheroy", 2005).isEqualTo(Bottle("Coucheroy", 2009))
26+
val isEqual = Bottle("Coucheroy", 2005, RED).isEqualTo(Bottle("Coucheroy", 2009, RED))
2527

2628
expectThat(isEqual).isFalse()
2729
}
2830

2931
@Test
3032
fun `should not be equals if name is different`() {
31-
val isEqual = Bottle("Coucheroy", 2005).isEqualTo(Bottle("Pedesclaux", 2009))
33+
val isEqual = Bottle("Coucheroy", 2005, RED).isEqualTo(Bottle("Pedesclaux", 2009, RED))
3234

3335
expectThat(isEqual).isFalse()
3436
}
3537

3638
@Test
3739
fun `should not be same instance even if name and year are equals`() {
38-
val isEqual = Bottle("Coucheroy", 2005).isSameInstance(Bottle("Coucheroy", 2005))
40+
val isEqual = Bottle("Coucheroy", 2005, RED).isSameInstance(Bottle("Coucheroy", 2005, RED))
3941

4042
expectThat(isEqual).isFalse()
4143
}
4244

4345
@Test
4446
fun `should be same instance`() {
45-
val bottle = Bottle("Coucheroy", 2005)
47+
val bottle = Bottle("Coucheroy", 2005, RED)
4648
val isEqual = bottle.isSameInstance(bottle)
4749

4850
expectThat(isEqual).isTrue()
4951
}
5052
}
53+
54+
@Nested
55+
inner class ToString {
56+
57+
@Test
58+
fun `should describe the bottle of red`() {
59+
val s = Bottle("Coucheroy", 2005, RED).toString()
60+
61+
expectThat(s).isEqualTo("Bouteille de Coucheroy rouge de 2005")
62+
}
63+
64+
@Test
65+
fun `should describe the bottle of white`() {
66+
val s = Bottle("Yquem", 2006, WHITE).toString()
67+
68+
expectThat(s).isEqualTo("Bouteille de Yquem blanc de 2006")
69+
}
70+
}
5171
}

0 commit comments

Comments
 (0)