Hey everyone i'm struggling with testing and injec...
# tornadofx
a
Hey everyone i'm struggling with testing and injection ... Maybe somebody could give me a hand. I'm trying to write some tests for my controller which holds templates. These templates are stored and read from a json file for persistence. To be able to test the controller without writing actual files i wanted to switch out the template parser when testing the controller. So i tried something like this..
Copy code
open class TemplateDatabase : Controller(), ITemplateDatabase {
	private val templateParser : ITemplateParser by params
    ... 
}
then normally use it like this:
Copy code
fun Component.templateDatabase() = inject<TemplateDatabase>(params = mapOf("templateParser" to TemplateParser()))
and for testing i would use something like this:
Copy code
internal class TemplateDatabaseTest : Component() {

	val templateDatabase : ITemplateDatabase by inject<TemplateDatabase>(params = mapOf("templateParser" to MockTemplateParser()))

init {
		FX.setPrimaryStage(Scope(), FxToolkit.registerPrimaryStage())
	}
...
}
But now I need the inheritance of the component to be able to use inject which makes it necessary to setup this FXToolkit ... which altogether doesn't seems the right way. Any help would be appreciated.