-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathBuilderTest.kt
33 lines (29 loc) · 974 Bytes
/
BuilderTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package org.vld.sdp.creational
import org.assertj.core.api.Assertions.* // ktlint-disable no-wildcard-imports
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BuilderTest {
// builder DSL
val expectedCar: Car = Car.build {
// direct assignment to variable Car Builder properties
make = "BMW"
model = "X5"
year = 2017
}
@Test
@DisplayName("Given a car builder. When build a car. Then return a car instance")
fun givenCarBuilder_whenBuildCar_thenReturnCarInstance() {
// Given & When
// builder DSL
val car = Car.build {
// call Car Builder functions to initialize variable Car Builder properties
make { "BMW" }
model { "X5" }
year { 2017 }
}
// Then
assertThat(car).isEqualTo(expectedCar)
}
}