Skip to content

Commit 1c49a4c

Browse files
pbourseauCLOVIS-AI
authored andcommitted
tp12 step 4 solution
1 parent 41c0a58 commit 1c49a4c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

tp12/src/test/kotlin/fmt/kotlin/fundamentals/CellarTest.kt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ import strikt.assertions.isEqualTo
88
import strikt.assertions.isNotNull
99

1010
class CellarTest {
11+
lateinit var cellar: Cellar
1112

12-
//Écrire le Étant donné que dans un beforeEach pour ne pas dupliquer le code
13-
14-
@Test
15-
fun `Should take first matching bottle Junit`() {
16-
//Étant donné que
17-
val cellar = Cellar(5)
13+
@BeforeEach
14+
fun initCellar() {
15+
cellar = Cellar(5)
1816

1917
cellar.addBottle(Bottle("Haut-Brion", 1997, WineColor.RED))
2018
cellar.addBottle(Bottle("Margaux", 2012, WineColor.WHITE))
2119
cellar.addBottle(Bottle("Pétrus", 2008, WineColor.RED))
20+
}
2221

22+
@Test
23+
fun `Should take first matching bottle Junit`() {
2324
//Lorsque
2425
val bottle = cellar.takeSpecificBottle("Margaux", 2012, WineColor.WHITE)
2526

@@ -29,5 +30,16 @@ class CellarTest {
2930
assertEquals(WineColor.WHITE, bottle?.color)
3031
}
3132

32-
//Écrire la même fonction que celle en Junit mais cette fois avec les assertions de Strikt
33+
@Test
34+
fun `Should take first matching bottle Strikt`() {
35+
//Lorsque
36+
val bottle = cellar.takeSpecificBottle("Margaux", 2012, WineColor.WHITE)
37+
38+
//Alors
39+
expectThat(bottle).isNotNull().and {
40+
get { name }.isEqualTo("Margaux")
41+
get { year }.isEqualTo(2012)
42+
get { color }.isEqualTo(WineColor.WHITE)
43+
}
44+
}
3345
}

0 commit comments

Comments
 (0)