Swinject/SwinjectStoryboard

Instances inside Container are different in app and test enviroment

FrangSierra opened this issue · 1 comments

Hello,

I'm using the Library right now and during the last days I was doing some UI-tests retrieving some data market as Singleton from the SwinjectStoryboard instance.

The thing is that when I try to retrieve an unique instance from the library:

override func setUp() {
		accountStore = SwinjectStoryboard.defaultContainer.resolve(AccountStore.self)!
		super.setUp()
	}

The instance is not the same that I have on my ViewController, even when the Scope is ObjectScope.container :

class AccountStoreAssembly: Assembly {
    func assemble(container: Container) {
        container.register(AccountStoreController.self) { _ in
            AccountStoreController(dispatcher: container.resolve(Dispatcher.self)!,
                    repository: container.resolve(LumiereService.self)!)
        }.inObjectScope(ObjectScope.container)

        container.register(AccountStore.self) { _ in
            AccountStore(controller: container.resolve(AccountStoreController.self)!,
                    dispatcher: container.resolve(Dispatcher.self)!,
                    repository: container.resolve(LumiereService.self)!)
        }.inObjectScope(ObjectScope.container)
    }
}

This is normal? There is no way to keep the same instance for both places? Tests and normal application controllers? Is this an issue or it works as designed?

Thank you so much in advance!

I'm afraid I don't quite understand what is the problem - can you clarify?
What do you mean by environment in your question? How did you compare instances between these environments?