Splitting heartBeat to heartBeat1 and hearBeat2 for more clear asserting

This commit is contained in:
Kyriakos Tharrouniatis 2020-02-17 00:14:01 +00:00
parent 6a89e88999
commit 11d92f90d5

View File

@ -225,18 +225,19 @@ class ObservablesTests {
@Test @Test
fun `FlowSafeSubject subscribes by default FlowSafeSubscribers, wrapped Observers will survive errors from onNext`() { fun `FlowSafeSubject subscribes by default FlowSafeSubscribers, wrapped Observers will survive errors from onNext`() {
var heartBeat = 0 var heartBeat1 = 0
var heartBeat2 = 0
val source = FlowSafeSubject(PublishSubject.create<Int>()) val source = FlowSafeSubject(PublishSubject.create<Int>())
source.subscribe { runNo -> source.subscribe { runNo ->
// subscribes with a FlowSafeSubscriber // subscribes with a FlowSafeSubscriber
heartBeat++ heartBeat1++
if (runNo == 1) { if (runNo == 1) {
throw IllegalStateException() throw IllegalStateException()
} }
} }
source.subscribe { runNo -> source.subscribe { runNo ->
// subscribes with a FlowSafeSubscriber // subscribes with a FlowSafeSubscriber
heartBeat++ heartBeat2++
if (runNo == 2) { if (runNo == 2) {
throw IllegalStateException() throw IllegalStateException()
} }
@ -249,7 +250,8 @@ class ObservablesTests {
source.onNext(2) // first observer will run, second observer will run and throw source.onNext(2) // first observer will run, second observer will run and throw
} }
source.onNext(3) // both observers will run source.onNext(3) // both observers will run
assertEquals(5, heartBeat) assertEquals(3, heartBeat1)
assertEquals(2, heartBeat2)
} }
@Test @Test