-
Notifications
You must be signed in to change notification settings - Fork 14
/
BridgeTest.kt
41 lines (37 loc) · 1.69 KB
/
BridgeTest.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
34
35
36
37
38
39
40
41
package org.vld.sdp.structural
import org.assertj.core.api.Assertions.* // ktlint-disable no-wildcard-imports
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import java.util.stream.Stream
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class BridgeTest {
@DisplayName("Given a device and a vendor. When switch on the device of the vendor. Then the vendor supports the device")
@ParameterizedTest(name = "{1}")
@MethodSource("deviceVendorProvider")
fun givenDeviceAndVendor_whenSwitchOnVendorDevice_thenVendorSupportsDevice(
device: Device,
expectedSupport: String
) {
// Given & When
// Abstractions: Phone and Tablet devices. Implementations: Xiaomi and Nokia vendors
// client only uses the Device Abstraction interface
val support = device.switchOn()
// Then
assertThat(support).isEqualTo(expectedSupport)
}
fun deviceVendorProvider(): Stream<Arguments> {
// Implementations
val xiaomi: Vendor = XiaomiVendor()
val nokia: Vendor = NokiaVendor()
// instantiate Abstractions (Phone and Tablet devices) by providing Implementations (Xiaomi and Nokia vendors)
return Stream.of(
Arguments.of(PhoneDevice(xiaomi), "Xiaomi supports Phone"),
Arguments.of(PhoneDevice(nokia), "Nokia supports Phone"),
Arguments.of(TabletDevice(xiaomi), "Xiaomi supports Tablet"),
Arguments.of(TabletDevice(nokia), "Nokia supports Tablet")
)
}
}