當前位置: 首頁>>代碼示例>>Java>>正文


Java TestSubscriber.assertUnsubscribed方法代碼示例

本文整理匯總了Java中rx.observers.TestSubscriber.assertUnsubscribed方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.assertUnsubscribed方法的具體用法?Java TestSubscriber.assertUnsubscribed怎麽用?Java TestSubscriber.assertUnsubscribed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rx.observers.TestSubscriber的用法示例。


在下文中一共展示了TestSubscriber.assertUnsubscribed方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testManagerViewSubscriptions_WithDetach_ShouldUnsubcribe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManagerViewSubscriptions_WithDetach_ShouldUnsubcribe() throws Exception {
    mPresenter.create();
    mPresenter.attachView(mView);
    TestSubscriber<Void> firstSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> secondSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> thirdSubscriber = new TestSubscriber<>();

    mSubscriptionHandler
            .manageViewSubscriptions(firstSubscriber, secondSubscriber, thirdSubscriber);
    assertThat(firstSubscriber.isUnsubscribed(), equalTo(false));
    assertThat(secondSubscriber.isUnsubscribed(), equalTo(false));
    assertThat(thirdSubscriber.isUnsubscribed(), equalTo(false));

    mPresenter.detachView();
    firstSubscriber.assertUnsubscribed();
    secondSubscriber.assertUnsubscribed();
    thirdSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例2: testManageSubscriptions_WithDetach_ShouldUnsubcribe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageSubscriptions_WithDetach_ShouldUnsubcribe() throws Exception {
    mPresenter.create();
    mPresenter.attachView(mView);
    TestSubscriber<Void> firstSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> secondSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> thirdSubscriber = new TestSubscriber<>();

    mSubscriptionHandler
            .manageViewSubscriptions(firstSubscriber, secondSubscriber, thirdSubscriber);
    assertThat(firstSubscriber.isUnsubscribed(), equalTo(false));
    assertThat(secondSubscriber.isUnsubscribed(), equalTo(false));
    assertThat(thirdSubscriber.isUnsubscribed(), equalTo(false));

    mPresenter.detachView();
    firstSubscriber.assertUnsubscribed();
    secondSubscriber.assertUnsubscribed();
    thirdSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例3: testManageSubscriptions_WithAlreadyUnsubscribedSubscription_ShouldDoNothing

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageSubscriptions_WithAlreadyUnsubscribedSubscription_ShouldDoNothing()
        throws Exception {
    TestSubscriber<Void> firstSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> secondSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> thirdSubscriber = new TestSubscriber<>();
    firstSubscriber.unsubscribe();
    secondSubscriber.unsubscribe();
    thirdSubscriber.unsubscribe();

    mSubscriptionHandler.manageSubscriptions(firstSubscriber, secondSubscriber, thirdSubscriber);

    firstSubscriber.assertUnsubscribed();
    secondSubscriber.assertUnsubscribed();
    thirdSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例4: testManageSubscriptions_WithDestroy_ShouldUnsubscribe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageSubscriptions_WithDestroy_ShouldUnsubscribe() throws Exception {
    mPresenter.create();
    TestSubscriber<Void> firstSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> secondSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> thirdSubscriber = new TestSubscriber<>();

    mSubscriptionHandler.manageSubscriptions(firstSubscriber, secondSubscriber, thirdSubscriber);
    assertThat(firstSubscriber.isUnsubscribed(), equalTo(false));
    assertThat(secondSubscriber.isUnsubscribed(), equalTo(false));
    assertThat(thirdSubscriber.isUnsubscribed(), equalTo(false));
    mPresenter.destroy();
    firstSubscriber.assertUnsubscribed();
    secondSubscriber.assertUnsubscribed();
    thirdSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例5: testActivityObservableBindLifecycle

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testActivityObservableBindLifecycle() throws Exception {
  final Observable<Object> observable = PublishSubject.create().asObservable();

  TestSubscriber<Object> testSubscriber = TestSubscriber.create();

  ActivityController controller = Robolectric.buildActivity(TestActivity.class).create().start();
  NaviActivity activity = (NaviActivity) controller.get();
  this.presenter.bind(activity);

  this.presenter.bindLifecycle(observable, testSubscriber);

  controller.create();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.start();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.resume();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.pause();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.stop();
  assertFalse(testSubscriber.isUnsubscribed());
  controller.destroy();
  testSubscriber.assertCompleted();
  testSubscriber.assertUnsubscribed();
}
 
開發者ID:ezhome,項目名稱:Android-RxPresenter,代碼行數:26,代碼來源:RxPresenterTest.java

示例6: states_should_stopObservingStateChanges

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void states_should_stopObservingStateChanges() {
  //GIVEN
  Store<Integer> store = new Store<>(0);
  TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();
  final Subscription subscription = states(store).subscribe(testSubscriber);

  //WHEN
  subscription.unsubscribe();
  store.dispatch(integer -> integer + 1);
  final Integer state = store.getState();

  //THEN
  testSubscriber.assertNoTerminalEvent();
  testSubscriber.assertValue(0);
  testSubscriber.assertUnsubscribed();
  assertThat(state, is(1));
}
 
開發者ID:groupon,項目名稱:grox,代碼行數:19,代碼來源:RxStoresTest.java

示例7: testManageSubscription_WithAlreadyUnsubscribedSubscription_ShouldDoNothing

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageSubscription_WithAlreadyUnsubscribedSubscription_ShouldDoNothing()
        throws Exception {
    TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();
    testSubscriber.unsubscribe();

    mSubscriptionHandler.manageSubscription(testSubscriber);

    testSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例8: testManageSubscription_WithDestroy_ShouldUnsubscribe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageSubscription_WithDestroy_ShouldUnsubscribe() throws Exception {
    mPresenter.create();
    TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();

    mSubscriptionHandler.manageSubscription(testSubscriber);
    assertThat(testSubscriber.isUnsubscribed(), equalTo(false));

    mPresenter.destroy();
    testSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例9: testManageViewSubscription_WithDetachSingleSub_ShouldUnsubscribe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageViewSubscription_WithDetachSingleSub_ShouldUnsubscribe()
        throws Exception {
    mPresenter.create();
    mPresenter.attachView(mView);
    TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();

    mSubscriptionHandler.manageViewSubscription(testSubscriber);
    assertThat(testSubscriber.isUnsubscribed(), equalTo(false));

    mPresenter.detachView();
    testSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例10: testManageViewSubscription_WithDetachView_ShouldUnsubscribe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageViewSubscription_WithDetachView_ShouldUnsubscribe() throws Exception {
    mPresenter.create();
    mPresenter.attachView(mView);
    TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();

    mSubscriptionHandler.manageViewSubscription(testSubscriber);
    mPresenter.detachView();

    testSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例11: testManageViewSubscriptions_WithOneAlreadyUnsubscribed_ShouldNotAddToSubscription

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testManageViewSubscriptions_WithOneAlreadyUnsubscribed_ShouldNotAddToSubscription()
        throws Exception {
    mPresenter.create();
    mPresenter.attachView(mView);
    TestSubscriber<Void> firstSubscriber = new TestSubscriber<>();
    TestSubscriber<Void> secondSubscriber = new TestSubscriber<>();
    secondSubscriber.unsubscribe();

    mSubscriptionHandler.manageViewSubscriptions(firstSubscriber, secondSubscriber);

    assertThat(firstSubscriber.isUnsubscribed(), equalTo(false));
    secondSubscriber.assertUnsubscribed();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:RxTiPresenterSubscriptionHandlerTest.java

示例12: testOneByOneUnsubscribe

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
public void testOneByOneUnsubscribe() {
    insertEntities(1000);
    RxQuery<TestEntity> bigQuery = daoSession.getTestEntityDao().queryBuilder().rx();
    TestSubscriber<TestEntity> testSubscriber = new TestSubscriber<>();
    Observable<TestEntity> observable = bigQuery.oneByOne();
    Subscription subscription = observable.subscribe(testSubscriber);
    subscription.unsubscribe();
    testSubscriber.assertUnsubscribed();
    int count = testSubscriber.getValueCount();
    testSubscriber.awaitTerminalEvent(100, TimeUnit.MILLISECONDS);
    int count2 = testSubscriber.getValueCount();
    DaoLog.d("Count 1: " + count + " vs. count 2: " + count2);
    // Not strictly multi-threading correct, but anyway:
    assertTrue(count2 < 1000);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RxQueryTest.java

示例13: testFragmentObservableBindLifecycle

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testFragmentObservableBindLifecycle() throws Exception {
  final Observable<Object> observable = PublishSubject.create().asObservable();

  TestSubscriber<Object> testSubscriber = TestSubscriber.create();
  NaviFragment fragment = new TestFragment();
  this.presenter.bind(fragment);

  startFragment(fragment);
  this.presenter.bindLifecycle(observable, Schedulers.test(), testSubscriber);

  fragment.onAttach(null);
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onCreate(null);
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onViewCreated(null, null);
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onStart();
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onResume();
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onPause();
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onStop();
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onDestroyView();
  testSubscriber.assertCompleted();
  testSubscriber.assertUnsubscribed();
}
 
開發者ID:ezhome,項目名稱:Android-RxPresenter,代碼行數:29,代碼來源:RxPresenterTest.java

示例14: testActivityObservableBindUntilEvent

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testActivityObservableBindUntilEvent() throws Exception {
  final Observable<Object> observable = PublishSubject.create().asObservable();

  TestSubscriber<Object> testSubscriber = TestSubscriber.create();
  NaviFragment fragment = new TestFragment();
  this.presenter.bind(fragment);

  startFragment(fragment);
  this.presenter.bindUntilEvent(observable, FragmentEvent.STOP, testSubscriber);

  fragment.onAttach(null);
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onCreate(null);
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onViewCreated(null, null);
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onStart();
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onResume();
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onPause();
  assertFalse(testSubscriber.isUnsubscribed());
  fragment.onStop();
  testSubscriber.assertCompleted();
  testSubscriber.assertUnsubscribed();
  fragment.onDestroyView();
  testSubscriber.assertCompleted();
  testSubscriber.assertUnsubscribed();
}
 
開發者ID:ezhome,項目名稱:Android-RxPresenter,代碼行數:30,代碼來源:RxPresenterTest.java


注:本文中的rx.observers.TestSubscriber.assertUnsubscribed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。