Created
July 6, 2020 06:47
-
-
Save romainbsl/f6c5a69ea77b697dc00a5a4fe22fc151 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class LoginPresenterTest : DIAware { | |
| override val di = DI { | |
| import(loginModule, allowOverride = true) | |
| bind<AuthApi>(overrides = true) with singleton { AuthApiSuccess() } | |
| bind<TokenRepository>(overrides = true) with singleton { TokenRepositoryLoggedIn() } | |
| bind() from provider { TestLoginView() } | |
| } | |
| @Test | |
| fun test01_attachView() { | |
| val presenter: Login.Presenter by instance() | |
| val loginView: TestLoginView by instance() | |
| presenter.attachView(loginView) | |
| assertNull(loginView.loginSuccess) | |
| assertNull(loginView.loginError) | |
| } | |
| @Test | |
| fun test02_checkAuthentication() { | |
| val presenter: Login.Presenter by instance() | |
| val loginView: TestLoginView by instance() | |
| presenter.attachView(loginView) | |
| presenter.checkAuthentication() | |
| assertEquals(true, loginView.loginSuccess) | |
| assertNull(loginView.loginError) | |
| } | |
| @Test | |
| fun test03_authenticate() { | |
| val presenter: LoginPresenterImpl by instance() | |
| val loginView: TestLoginView by instance() | |
| presenter.attachView(loginView) | |
| presenter.authenticate("my_secret_code") | |
| assertEquals(true, loginView.loginSuccess) | |
| assertNull(loginView.loginError) | |
| } | |
| // ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment