Exemplo n.º 1
0
  @Test
  public void testAsSetAction() throws Exception {
    final Value<String> value = Value.create("1");
    assertEquals(value.get(), "1");
    TestSubscriber<String> testSubscriber = new TestSubscriber<>();
    Subscription subscribe = value.asObservable().subscribe(testSubscriber);

    value.asSetAction().call("2");

    testSubscriber.assertValueCount(2);
    testSubscriber.assertValues("1", "2");
  }
Exemplo n.º 2
0
  @Test
  public void testCreatePublish() throws Exception {

    final Value<String> value = Value.createPublish("1");
    assertEquals(value.get(), "1");
    TestSubscriber<String> testSubscriber = new TestSubscriber<>();
    Subscription subscribe = value.asObservable().subscribe(testSubscriber);

    testSubscriber.assertValueCount(0);

    value.set("2");

    testSubscriber.assertValueCount(1);
    testSubscriber.assertValues("2");

    subscribe.unsubscribe();

    testSubscriber = new TestSubscriber<>();
    value.asObservable().subscribe(testSubscriber);

    testSubscriber.assertValueCount(0);
  }