use of rx.schedulers.TestScheduler in project frodo by android10.
the class LogStreamObservableTest method shouldFillInObservableItemsInfo.
@Test
public void shouldFillInObservableItemsInfo() throws Throwable {
final TestScheduler testScheduler = new TestScheduler();
loggableObservable.get(observableRule.stringType()).delay(2, TimeUnit.SECONDS).subscribeOn(testScheduler).subscribe(subscriber);
testScheduler.advanceTimeBy(1, TimeUnit.SECONDS);
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
final ObservableInfo observableInfo = loggableObservable.getInfo();
final Optional<Integer> totalEmittedItems = observableInfo.getTotalEmittedItems();
final Optional<Long> totalExecutionTime = observableInfo.getTotalExecutionTime();
assertThat(totalEmittedItems.isPresent()).isTrue();
assertThat(totalEmittedItems.get()).isEqualTo(1);
}
use of rx.schedulers.TestScheduler in project RxLifecycle by trello.
the class UntilCorrespondingEventSingleTransformerTest method setup.
@Before
public void setup() {
lifecycle = PublishSubject.create();
testSubscriber = new TestSubscriber<>();
testScheduler = new TestScheduler();
}
use of rx.schedulers.TestScheduler in project RxLifecycle by trello.
the class UntilEventSingleTransformerTest method setup.
@Before
public void setup() {
lifecycle = PublishSubject.create();
testSubscriber = new TestSubscriber<>();
testScheduler = new TestScheduler();
}
use of rx.schedulers.TestScheduler in project RxLifecycle by trello.
the class UntilLifecycleSingleTransformerTest method setup.
@Before
public void setup() {
lifecycle = PublishSubject.create();
testSubscriber = new TestSubscriber<>();
testScheduler = new TestScheduler();
}
use of rx.schedulers.TestScheduler in project AnDevCon-RxPatterns by colintheshots.
the class Example16Test method should_test_observable_interval.
// http://stackoverflow.com/questions/26699147/how-to-use-testscheduler-in-rxjava
@Test
public void should_test_observable_interval() {
TestScheduler scheduler = new TestScheduler();
final List<Long> result = new ArrayList<>();
Observable.interval(1, TimeUnit.SECONDS, scheduler).take(5).subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
result.add(aLong);
}
});
assertTrue(result.isEmpty());
scheduler.advanceTimeBy(2, TimeUnit.SECONDS);
assertEquals(2, result.size());
scheduler.advanceTimeBy(10, TimeUnit.SECONDS);
assertEquals(5, result.size());
}
Aggregations