diff --git a/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/collections/ListExample.kt b/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/collections/ListExample.kt new file mode 100644 index 0000000000..a0dd04a760 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections/src/main/kotlin/com/baeldung/collections/ListExample.kt @@ -0,0 +1,13 @@ +package com.baeldung.collections + +import kotlin.collections.List + +class ListExample { + fun createList(): List { + return listOf("one", "two", "three") + } + + fun createMutableList(): MutableList { + return mutableListOf("Berlin", "Kolkata", "London") + } +} \ No newline at end of file diff --git a/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/collections/ListExampleUnitTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/collections/ListExampleUnitTest.kt new file mode 100644 index 0000000000..46e4d09369 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/collections/ListExampleUnitTest.kt @@ -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")) + } + +} \ No newline at end of file