diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-04-21 17:00:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-21 17:00:09 +0200 |
| commit | 10dfc257de65cbbd1e25d1d7f5833bfb687d85ed (patch) | |
| tree | 48b102c4d45b366abd8d0d368c31d6c0596ac30f /simulator/opendc-utils/src | |
| parent | b4d1289bbd9539c041e8aeb39bb8962628399809 (diff) | |
| parent | 62678b2890a7f3640836b99ca2fec9efd7485929 (diff) | |
simulator: Introduce SimulationCoroutineDispatcher (#120)
This change introduces the SimulationCoroutineDispatcher implementation which replaces the TestCoroutineDispatcher for running single-threaded simulations.
Diffstat (limited to 'simulator/opendc-utils/src')
| -rw-r--r-- | simulator/opendc-utils/src/test/kotlin/org/opendc/utils/TimerSchedulerTest.kt | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/simulator/opendc-utils/src/test/kotlin/org/opendc/utils/TimerSchedulerTest.kt b/simulator/opendc-utils/src/test/kotlin/org/opendc/utils/TimerSchedulerTest.kt index 1fcb5d38..101a6546 100644 --- a/simulator/opendc-utils/src/test/kotlin/org/opendc/utils/TimerSchedulerTest.kt +++ b/simulator/opendc-utils/src/test/kotlin/org/opendc/utils/TimerSchedulerTest.kt @@ -23,11 +23,10 @@ package org.opendc.utils import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runBlockingTest import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import org.opendc.simulator.utils.DelayControllerClockAdapter +import org.opendc.simulator.core.runBlockingSimulation /** * A test suite for the [TimerScheduler] class. @@ -36,8 +35,7 @@ import org.opendc.simulator.utils.DelayControllerClockAdapter internal class TimerSchedulerTest { @Test fun testBasicTimer() { - runBlockingTest { - val clock = DelayControllerClockAdapter(this) + runBlockingSimulation { val scheduler = TimerScheduler<Int>(coroutineContext, clock) scheduler.startSingleTimer(0, 1000) { @@ -49,8 +47,7 @@ internal class TimerSchedulerTest { @Test fun testCancelNonExisting() { - runBlockingTest { - val clock = DelayControllerClockAdapter(this) + runBlockingSimulation { val scheduler = TimerScheduler<Int>(coroutineContext, clock) scheduler.cancel(1) @@ -60,8 +57,7 @@ internal class TimerSchedulerTest { @Test fun testCancelExisting() { - runBlockingTest { - val clock = DelayControllerClockAdapter(this) + runBlockingSimulation { val scheduler = TimerScheduler<Int>(coroutineContext, clock) scheduler.startSingleTimer(0, 1000) { @@ -79,8 +75,7 @@ internal class TimerSchedulerTest { @Test fun testCancelAll() { - runBlockingTest { - val clock = DelayControllerClockAdapter(this) + runBlockingSimulation { val scheduler = TimerScheduler<Int>(coroutineContext, clock) scheduler.startSingleTimer(0, 1000) { @@ -97,8 +92,7 @@ internal class TimerSchedulerTest { @Test fun testOverride() { - runBlockingTest { - val clock = DelayControllerClockAdapter(this) + runBlockingSimulation { val scheduler = TimerScheduler<Int>(coroutineContext, clock) scheduler.startSingleTimer(0, 1000) { @@ -115,8 +109,7 @@ internal class TimerSchedulerTest { @Test fun testStopped() { - runBlockingTest { - val clock = DelayControllerClockAdapter(this) + runBlockingSimulation { val scheduler = TimerScheduler<Int>(coroutineContext, clock) scheduler.close() @@ -131,8 +124,7 @@ internal class TimerSchedulerTest { @Test fun testNegativeDelay() { - runBlockingTest { - val clock = DelayControllerClockAdapter(this) + runBlockingSimulation { val scheduler = TimerScheduler<Int>(coroutineContext, clock) assertThrows<IllegalArgumentException> { |
