File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed
main/kotlin/fmt/kotlin/fundamentals
test/kotlin/fmt/kotlin/fundamentals Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change
1
+ package fmt.kotlin.fundamentals
2
+
3
+ data class Barrel (
4
+ val capacity : Int
5
+ )
Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ package fmt.kotlin.fundamentals
3
3
import jdk.internal.org.jline.utils.Colors.s
4
4
5
5
data class Cellar (
6
- val bottles : List <Bottle >
6
+ val bottles : List <Bottle >,
7
+ val barrels : List <Barrel > = emptyList()
7
8
) {
8
9
fun describeAll () = callOnEveryBottle(Bottle ::describe)
9
10
Original file line number Diff line number Diff line change 1
1
package fmt.kotlin.fundamentals
2
2
3
- import org.junit.jupiter.api.Assertions.*
4
3
import org.junit.jupiter.api.Nested
5
4
import org.junit.jupiter.api.Test
6
5
import strikt.api.expectThat
6
+ import strikt.assertions.all
7
+ import strikt.assertions.hasSize
7
8
import strikt.assertions.isEqualTo
9
+ import strikt.assertions.withFirst
8
10
9
11
class CellarTest {
10
12
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
+
11
46
@Nested
12
47
inner class OnEveryBottle {
13
48
You can’t perform that action at this time.
0 commit comments