forked from kotlin-hands-on/intro-coroutines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRequest9RxProgressKtTest.kt
34 lines (27 loc) · 1.12 KB
/
Request9RxProgressKtTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package tasks
import contributors.*
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import java.util.concurrent.TimeUnit
internal class Request9RxProgressKtTest {
@Before
fun setUp() {
testScheduler.advanceTimeTo(0, TimeUnit.MILLISECONDS)
}
@Test
fun loadContributorsReactiveProgress() {
val testObserver = loadContributorsReactiveProgress(MockGithubService, testRequestData, testScheduler).test()
testObserver.assertNoValues()
val startTime = testScheduler.now(TimeUnit.MILLISECONDS)
concurrentProgressResults.forEachIndexed { index: Int, expected: TestResults ->
println("index: $index, expected: $expected")
testScheduler.advanceTimeTo(expected.timeFromStart, TimeUnit.MILLISECONDS)
testObserver.assertValueAt(index, expected.users)
val time = testScheduler.now(TimeUnit.MILLISECONDS) - startTime
Assert.assertEquals("Expected intermediate result after virtual ${expected.timeFromStart} ms:",
expected.timeFromStart, time)
}
testObserver.assertComplete()
}
}