Skip to content

Commit

Permalink
tp9 step 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ctruchi committed Feb 14, 2025
1 parent 888e161 commit 3cc58af
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
10 changes: 8 additions & 2 deletions tp9/src/main/kotlin/fmt/kotlin/fundamentals/Bottle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ package fmt.kotlin.fundamentals

data class Bottle(
val name: String,
val year: Int
)
val year: Int,
val color: WineColor
)

enum class WineColor {
RED,
WHITE
}
2 changes: 2 additions & 0 deletions tp9/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ data class Cellar(
"Bouteille de ${name} de ${year}"
}
}

fun describeRedBottles() = ""
}
23 changes: 21 additions & 2 deletions tp9/src/test/kotlin/fmt/kotlin/fundamentals/CellarTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fmt.kotlin.fundamentals

import fmt.kotlin.fundamentals.WineColor.RED
import fmt.kotlin.fundamentals.WineColor.WHITE
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import strikt.api.expectThat
Expand All @@ -11,8 +13,8 @@ class CellarTest {
fun `should get bottles description`() {
val description = Cellar(
listOf(
Bottle("Coucheroy", 2005),
Bottle("Pedesclaux", 2009)
Bottle("Coucheroy", 2005, RED),
Bottle("Pedesclaux", 2009, RED)
)
).describeBottles()

Expand All @@ -21,4 +23,21 @@ class CellarTest {
Bouteille de Pedesclaux de 2009
""".trimIndent())
}

@Test
fun `should get red bottles description`() {
val description = Cellar(
listOf(
Bottle("Coucheroy", 2005, RED),
Bottle("Camarsac", 2018, WHITE),
Bottle("Pedesclaux", 2009, RED),
)
).describeRedBottles()

expectThat(description).isEqualTo("""
Bouteille de Coucheroy de 2005
Bouteille de blanc
Bouteille de Pedesclaux de 2009
""".trimIndent())
}
}

0 comments on commit 3cc58af

Please sign in to comment.