-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrinksTest.kt
More file actions
29 lines (22 loc) · 977 Bytes
/
DrinksTest.kt
File metadata and controls
29 lines (22 loc) · 977 Bytes
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
package kt.design.patterns.decorator
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
internal class DrinksTest {
@Test
fun `should serve drinks with additives and return a valid cost`() {
val noCafWithCinnamon = Cinnamon.withDrink(NonCaffeine())
val coffeeWithMilk = Milk.withDrink(Coffee())
assertEquals(2.7, noCafWithCinnamon.cost())
assertEquals(1.7, coffeeWithMilk.cost())
}
@Test
fun `should check costs and descriptions of the coffee and the coffee with additives`() {
val coffee = Coffee()
val coffeeWithMilk = Milk.withDrink(coffee)
val coffeeWithMilkAndCinnamon = Cinnamon.withDrink(coffeeWithMilk)
assertEquals(coffee.description, "Black coffee")
assertEquals(coffeeWithMilkAndCinnamon.description, "Black coffee, Milk, Cinnamon")
assertEquals(1.5, coffee.cost())
assertEquals(1.9, coffeeWithMilkAndCinnamon.cost())
}
}