Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1463 to allow several bindings of the same type
- Loading branch information
1 parent
32a10db
commit 9affdc3
Showing
5 changed files
with
51 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/koin-core/src/commonTest/kotlin/org/koin/dsl/ConstructorDSLTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.koin.dsl | ||
|
||
import org.koin.Simple | ||
import org.koin.core.logger.Level | ||
import org.koin.core.module.dsl.bind | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.core.qualifier.named | ||
import kotlin.test.Test | ||
import kotlin.test.assertNotNull | ||
import kotlin.test.assertNull | ||
import kotlin.test.assertTrue | ||
|
||
class ConstructorDSLTest { | ||
|
||
@Test | ||
fun test_reified_type_cosntructor(){ | ||
val koin = koinApplication { | ||
modules(module { | ||
singleOf<IClassA>(::ClassA) | ||
}) | ||
}.koin | ||
assertNotNull(koin.getOrNull<IClassA>()) | ||
assertNull(koin.getOrNull<ClassA>()) | ||
} | ||
|
||
@Test | ||
fun test_allow_extra_binds(){ | ||
|
||
val koin = koinApplication { | ||
printLogger(Level.DEBUG) | ||
modules(module { | ||
singleOf(::ClassA) { bind<IClassA>()} | ||
singleOf(::ClassA2) { bind<IClassA>()} | ||
}) | ||
}.koin | ||
|
||
assertNotNull(koin.getOrNull<IClassA>() is ClassA2) | ||
assertNotNull(koin.getOrNull<ClassA>()) | ||
assertNotNull(koin.getOrNull<ClassA2>()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters