Skip to content

Commit 9ea54cd

Browse files
committed
tp7 step 2
1 parent 90f28a2 commit 9ea54cd

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package fmt.kotlin.fundamentals
2+
3+
data class Barrel(
4+
val capacity: Int
5+
)

tp7/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package fmt.kotlin.fundamentals
33
import jdk.internal.org.jline.utils.Colors.s
44

55
data class Cellar(
6-
val bottles: List<Bottle>
6+
val bottles: List<Bottle>,
7+
val barrels: List<Barrel> = emptyList()
78
) {
89
fun describeAll() = callOnEveryBottle(Bottle::describe)
910

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
11
package fmt.kotlin.fundamentals
22

3-
import org.junit.jupiter.api.Assertions.*
43
import org.junit.jupiter.api.Nested
54
import org.junit.jupiter.api.Test
65
import strikt.api.expectThat
6+
import strikt.assertions.all
7+
import strikt.assertions.hasSize
78
import strikt.assertions.isEqualTo
9+
import strikt.assertions.withFirst
810

911
class CellarTest {
1012

13+
@Nested
14+
inner class Dsl {
15+
16+
@Test
17+
fun `should build a Cellar`() {
18+
val cellar = cellar {
19+
barrel {
20+
capacity = 225
21+
}
22+
barrel {
23+
capacity = 225
24+
}
25+
bottle {
26+
name = "Coucheroy"
27+
year = 2005
28+
}
29+
}
30+
31+
expectThat(cellar) {
32+
get { barrels }.hasSize(2)
33+
.all {
34+
get { capacity }.isEqualTo(225)
35+
}
36+
get { bottles }.hasSize(1)
37+
.withFirst {
38+
get { name }.isEqualTo("Coucheroy")
39+
get { year }.isEqualTo(2005)
40+
}
41+
42+
}
43+
}
44+
}
45+
1146
@Nested
1247
inner class OnEveryBottle {
1348

0 commit comments

Comments
 (0)