Skip to content

Commit 99f3546

Browse files
committed
tp7 step 1
1 parent ce11d41 commit 99f3546

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

tp7/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id("fmt.kotlin.fundamentals.gradle.component.tp")
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package fmt.kotlin.fundamentals
2+
3+
data class Bottle(
4+
val name: String,
5+
val year: Int
6+
) {
7+
fun describe() = "Bouteille de $name de $year"
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package fmt.kotlin.fundamentals
2+
3+
import jdk.internal.org.jline.utils.Colors.s
4+
5+
data class Cellar(
6+
val bottles: List<Bottle>
7+
) {
8+
fun describeAll(): String = TODO()
9+
10+
val years: String = TODO()
11+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package fmt.kotlin.fundamentals
2+
3+
import org.junit.jupiter.api.Assertions.*
4+
import org.junit.jupiter.api.Nested
5+
import org.junit.jupiter.api.Test
6+
import strikt.api.expectThat
7+
import strikt.assertions.isEqualTo
8+
9+
class CellarTest {
10+
11+
@Nested
12+
inner class OnEveryBottle {
13+
14+
val cellar = Cellar(
15+
bottles = listOf(
16+
Bottle("Coucheroy", 2005),
17+
Bottle("Pedesclaux", 2009),
18+
Bottle("Talbot", 2015),
19+
)
20+
)
21+
22+
@Test
23+
fun `should describe cellar`() {
24+
val description = cellar.describeAll()
25+
26+
expectThat(description).isEqualTo(
27+
"""
28+
29+
Bouteille de Coucheroy de 2005
30+
Bouteille de Pedesclaux de 2009
31+
Bouteille de Talbot de 2015
32+
""".trimIndent()
33+
)
34+
}
35+
36+
@Test
37+
fun `should get all years`() {
38+
val years = cellar.years
39+
40+
expectThat(years).isEqualTo(
41+
"""
42+
43+
2005
44+
2009
45+
2015
46+
""".trimIndent()
47+
)
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)