Initial commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package cl.carlost.kmpexcercises
|
||||
|
||||
class AndroidPlatform : Platform {
|
||||
override val name: String = "Android ${android.os.Build.VERSION.SDK_INT}"
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = AndroidPlatform()
|
||||
@@ -0,0 +1,12 @@
|
||||
package cl.carlost.kmpexcercises
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class AndroidGreetingTest {
|
||||
|
||||
@Test
|
||||
fun testExample() {
|
||||
assertTrue("Check Android is mentioned", Greeting().greet().contains("Android"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cl.carlost.kmpexcercises
|
||||
|
||||
class Greeting {
|
||||
private val platform: Platform = getPlatform()
|
||||
|
||||
fun greet(): String {
|
||||
return "Hello, ${platform.name}!"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cl.carlost.kmpexcercises
|
||||
|
||||
interface Platform {
|
||||
val name: String
|
||||
}
|
||||
|
||||
expect fun getPlatform(): Platform
|
||||
@@ -0,0 +1,12 @@
|
||||
package cl.carlost.kmpexcercises
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class CommonGreetingTest {
|
||||
|
||||
@Test
|
||||
fun testExample() {
|
||||
assertTrue(Greeting().greet().contains("Hello"), "Check 'Hello' is mentioned")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cl.carlost.kmpexcercises
|
||||
|
||||
import platform.UIKit.UIDevice
|
||||
|
||||
class IOSPlatform: Platform {
|
||||
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = IOSPlatform()
|
||||
@@ -0,0 +1,12 @@
|
||||
package cl.carlost.kmpexcercises
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class IosGreetingTest {
|
||||
|
||||
@Test
|
||||
fun testExample() {
|
||||
assertTrue(Greeting().greet().contains("iOS"), "Check iOS is mentioned")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user