use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class ObservableWindowWithStartEndObservableTest method before.
@Before
public void before() {
scheduler = new TestScheduler();
innerScheduler = scheduler.createWorker();
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class SchedulerWhenTest method testAsyncMaxConcurrent.
@Test
public void testAsyncMaxConcurrent() {
TestScheduler tSched = new TestScheduler();
SchedulerWhen sched = maxConcurrentScheduler(tSched);
TestSubscriber<Long> tSub = TestSubscriber.create();
asyncWork(sched).subscribe(tSub);
tSub.assertValueCount(0);
tSched.advanceTimeBy(0, SECONDS);
tSub.assertValueCount(0);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(2);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(4);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(5);
tSub.assertComplete();
sched.dispose();
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class SchedulerWhenTest method testAsyncDelaySubscription.
@Test
public void testAsyncDelaySubscription() {
final TestScheduler tSched = new TestScheduler();
SchedulerWhen sched = throttleScheduler(tSched);
TestSubscriber<Long> tSub = TestSubscriber.create();
asyncWork(sched).subscribe(tSub);
tSub.assertValueCount(0);
tSched.advanceTimeBy(0, SECONDS);
tSub.assertValueCount(0);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(1);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(1);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(2);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(2);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(3);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(3);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(4);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(4);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(5);
tSub.assertComplete();
sched.dispose();
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class SchedulerWhenTest method testSyncDelaySubscription.
@Test
public void testSyncDelaySubscription() {
final TestScheduler tSched = new TestScheduler();
SchedulerWhen sched = throttleScheduler(tSched);
TestSubscriber<Long> tSub = TestSubscriber.create();
syncWork(sched).subscribe(tSub);
tSub.assertValueCount(0);
tSched.advanceTimeBy(0, SECONDS);
tSub.assertValueCount(1);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(2);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(3);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(4);
tSched.advanceTimeBy(1, SECONDS);
tSub.assertValueCount(5);
tSub.assertComplete();
sched.dispose();
}
use of io.reactivex.schedulers.TestScheduler in project RxJava by ReactiveX.
the class MaybeTimerTest method timer.
@Test
public void timer() {
final TestScheduler testScheduler = new TestScheduler();
final AtomicLong atomicLong = new AtomicLong();
Maybe.timer(2, TimeUnit.SECONDS, testScheduler).subscribe(new Consumer<Long>() {
@Override
public void accept(final Long value) throws Exception {
atomicLong.incrementAndGet();
}
});
assertEquals(0, atomicLong.get());
testScheduler.advanceTimeBy(1, TimeUnit.SECONDS);
assertEquals(0, atomicLong.get());
testScheduler.advanceTimeBy(1, TimeUnit.SECONDS);
assertEquals(1, atomicLong.get());
}
Aggregations