Created
July 4, 2023 09:07
-
-
Save KwabenBerko/f5f46cece20cd9cec2bf2b5e65616aa0 to your computer and use it in GitHub Desktop.
Mutex Enabled Component Test
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
@OptIn(ExperimentalCoroutinesApi::class) | |
class MutexEnabledComponentTest { | |
@Test | |
fun `should call refresh function only once`() = runTest { | |
val jobs = mutableListOf<Job>() | |
val component = MutexEnabledComponent() | |
repeat(10){ | |
jobs += launch { component.refresh() } | |
} | |
jobs.joinAll() | |
assertEquals(1, component.refreshesCount) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment