Created
February 24, 2021 14:16
-
-
Save prokash-sarkar/c9f260cd4ff35ebb32e9147f742a652d to your computer and use it in GitHub Desktop.
This file contains 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 MainViewModel : ViewModel() { | |
private var isSessionExpired = false | |
suspend fun checkSessionExpiry(): Boolean { | |
withContext(Dispatchers.IO) { | |
delay(5_000) // to simulate a heavy weight operations | |
isSessionExpired = true | |
} | |
return isSessionExpired | |
} | |
} | |
class MainViewModelTest { | |
@Test | |
fun testCheckSessionExpiry() = runBlocking { | |
val mainViewModel = MainViewModel() | |
val totalExecutionTime = measureTimeMillis { | |
val isSessionExpired = mainViewModel.checkSessionExpiry() | |
assertTrue(isSessionExpired) | |
} | |
print("Total Execution Time: $totalExecutionTime") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment