Skip to content

Instantly share code, notes, and snippets.

@romainbsl
Created July 6, 2020 06:47
Show Gist options
  • Select an option

  • Save romainbsl/f6c5a69ea77b697dc00a5a4fe22fc151 to your computer and use it in GitHub Desktop.

Select an option

Save romainbsl/f6c5a69ea77b697dc00a5a4fe22fc151 to your computer and use it in GitHub Desktop.
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