so I would like to inject this usecase that I have which returns the Result class, and the method to...
o
so I would like to inject this usecase that I have which returns the Result class, and the method to do that is suspendable so i am using
runTest{ }
to call it, but this is causing me to be unable to answer with the type that I want now, since it’s now expecting
TestResult
, I want to return
Result.success(obj)
Copy code
@ExperimentalCoroutinesApi
@Inject
fun firebaseSignInWithEmail(mock: FirebaseSignInWithEmail) {
    every {
        runTest {
            mock.invoke("anyEmail", "anyPassword")
        }
    } returns TestResult
}
This doesn’t complain since I supplied TestResult as a return type
this is the usecase I’m trying to inject
Copy code
class FirebaseSignInWithEmail @Inject constructor(
    private val firebaseAuth: FirebaseAuth
) {
    suspend operator fun invoke(email: String, password: String): Result<AuthResult> {

        return suspendCoroutine { cont ->
            firebaseAuth.signInWithEmailAndPassword(email, password)
                .addOnSuccessListener {
                    cont.resume(Result.success(it))
                }
                .addOnFailureListener {
                    cont.resumeWith(Result.failure(it))
                }
        }
    }
}
f
You should use coEvery instead of every and not runTest