Example #1
0
 @Test
 public void fromArray() {
   String[] items = new String[] {"one", "two", "three"};
   assertEquals((Long) 3L, Observable.fromArray(items).count().toBlocking().single());
   assertEquals("two", Observable.fromArray(items).skip(1).take(1).toBlocking().single());
   assertEquals("three", Observable.fromArray(items).takeLast(1).toBlocking().single());
 }
Example #2
0
  @Test
  public void testJustWithScheduler() {
    TestScheduler scheduler = new TestScheduler();
    Observable<Integer> observable = Observable.fromArray(1, 2).subscribeOn(scheduler);

    Subscriber<Integer> observer = TestHelper.mockSubscriber();

    observable.subscribe(observer);

    scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);

    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onNext(1);
    inOrder.verify(observer, times(1)).onNext(2);
    inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
  }