Is possible to test "() -> Unit?" with junit test?
I have the following NetworkUtils class
class NetworkUtils : NetworkContract{
/**
*Return success if the Internet connection is enought to make an request
*/
override fun isConnectedFast(onSuccess: () -> Unit?, onError: () -> Unit?) {
}
}
That is the interface
interface NetworkContract {
fun isConnectedFast(onSuccess: (() -> Unit?), onError: (() -> Unit?))
}
Here is my presenter where I wanna to check internet connection and do some requests
class Presenter(){
//some declarations
override fun onContinue(){
super.updateUserProfile({
super.updateImage({
//request success
},{
//request failed
})
},{
//some error received
})
}
}
And here is my Handler which is an interface
interface Hndler{
fun updateUserProfile(){
service.getProfile(id,token!!)
.subscribe({ response ->
onSuccess?.invoke()
}, { error ->
onError?.invoke()
})
}
}
I wanna to mock that somehow. Is that possible or not? If yes, please can you give me an example?