Finish assignment
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
parent
c016d3cf61
commit
af528d26c4
11 changed files with 145 additions and 25 deletions
35
src/test/kotlin/InvoiceTest.kt
Normal file
35
src/test/kotlin/InvoiceTest.kt
Normal file
|
@ -0,0 +1,35 @@
|
|||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
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
|
||||
|
||||
internal class InvoiceTest {
|
||||
|
||||
@ParameterizedTest(name = "Test that the invoice has {0} products and a total price of {1}")
|
||||
@MethodSource("provideValidInvoices")
|
||||
fun getTotalPrice(numberOfProducts: Int, totalPrice: Float, invoice: Invoice) {
|
||||
assertEquals(numberOfProducts, invoice.products.size)
|
||||
assertEquals(totalPrice, invoice.totalPrice)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test invalid columns`() {
|
||||
assertThrows<ParseException> {
|
||||
Invoice.fromFile("src/test/resources/invoice_with_invalid_column.txt")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun provideValidInvoices(): Stream<Arguments> {
|
||||
return Stream.of(
|
||||
Arguments.of(6, 3950.3f, Invoice.fromFile("src/test/resources/invoice1.txt")),
|
||||
Arguments.of(6, 3950.3f, Invoice.fromFile("src/test/resources/invoice2.txt")),
|
||||
Arguments.of(6, 3950.3f, Invoice.fromFile("src/test/resources/invoice3.txt"))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue