Added list creation and unit tests

This commit is contained in:
Anirban Chatterjee 2020-06-01 15:31:46 +02:00
parent 9ae7596d5e
commit 69a43cc613
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,13 @@
package com.baeldung.collections
import kotlin.collections.List
class ListExample {
fun createList(): List<String> {
return listOf("one", "two", "three")
}
fun createMutableList(): MutableList<String> {
return mutableListOf("Berlin", "Kolkata", "London")
}
}

View File

@ -0,0 +1,18 @@
package com.baeldung.collections
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotEquals
import kotlin.test.assertTrue
class ListExampleUnitTest {
private val classUnderTest: ListExample = ListExample()
@Test
fun whenListIsCreated_thenContainsElements() {
assertTrue(classUnderTest.createList().contains("two"))
assertTrue(classUnderTest.createMutableList().contains("Berlin"))
}
}