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


Java TestObserver.assertResult方法代碼示例

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


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

示例1: test_just_new

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void test_just_new() {
	Observable<Integer> observable = Observable.just(12, 34, 6);
	TestObserver<Integer> testObserver = new TestObserver<>();

	observable.subscribe(testObserver);

	List<Integer> list = new ArrayList();
	testObserver.assertComplete();
	testObserver.assertResult(12, 34, 6);
	testObserver.assertValueCount(3);
	testObserver.assertNoErrors();
	testObserver.assertValueAt(2, (value) -> {
		// TODO Auto-generated method stub
		return value == 34;
	});

}
 
開發者ID:PacktPublishing,項目名稱:Reactive-Programming-With-Java-9,代碼行數:19,代碼來源:Modern_Testing.java

示例2: testForecast

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testForecast() throws Exception {
    server.enqueue(new MockResponse().setBody(responseExample));

    DarkSkyApi darkSkyApi = Utils.buildDarkSkyInstance(server.url("/"));

    Observable<JsonObject> forecast = darkSkyApi.forecast("", -1, -1);
    TestObserver<JsonObject> test = forecast.test();
    test.assertNoErrors();
    JsonObject expected = new Gson().fromJson(responseExample, JsonObject.class);
    test.assertResult(expected);
}
 
開發者ID:TechIsFun,項目名稱:RxJava2-weather-example,代碼行數:13,代碼來源:MockApiTest.java

示例3: rx_IsAllCountriesPopulationMoreThanOneMillion_Positive

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_IsAllCountriesPopulationMoreThanOneMillion_Positive() {
    TestObserver<Boolean> testObserver = countriesService
            .isAllCountriesPopulationMoreThanOneMillion(CountriesTestProvider.countriesPopulationMoreThanOneMillion())
            .test();
    testObserver.assertResult(true);
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:9,代碼來源:CountriesServiceSolvedTest.java

示例4: rx_IsAllCountriesPopulationMoreThanOneMillion_Negative

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_IsAllCountriesPopulationMoreThanOneMillion_Negative() {
    TestObserver<Boolean> testObserver = countriesService
            .isAllCountriesPopulationMoreThanOneMillion(allCountries)
            .test();
    testObserver.assertResult(false);
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:9,代碼來源:CountriesServiceSolvedTest.java

示例5: rx_GetCurrencyUsdIfNotFound_When_CountryFound

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_GetCurrencyUsdIfNotFound_When_CountryFound() {
    String countryRequested = "Austria";
    String expectedCurrencyValue = "EUR";
    TestObserver<String> testObserver = countriesService
            .getCurrencyUsdIfNotFound(countryRequested, allCountries)
            .test();
    testObserver.assertResult(expectedCurrencyValue);
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:11,代碼來源:CountriesServiceSolvedTest.java

示例6: rx_GetCurrencyUsdIfNotFound_When_CountryNotFound

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_GetCurrencyUsdIfNotFound_When_CountryNotFound() {
    String countryRequested = "Senegal";
    String expectedCurrencyValue = "USD";
    TestObserver<String> testObserver = countriesService
            .getCurrencyUsdIfNotFound(countryRequested, allCountries)
            .test();
    testObserver.assertResult(expectedCurrencyValue);
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:11,代碼來源:CountriesServiceSolvedTest.java

示例7: rx_SumPopulationOfCountries

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_SumPopulationOfCountries() {
    // hint: use "reduce" operator
    TestObserver<Long> testObserver = countriesService
            .sumPopulationOfCountries(allCountries)
            .test();
    testObserver.assertResult(CountriesTestProvider.sumPopulationOfAllCountries());
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:10,代碼來源:CountriesServiceSolvedTest.java

示例8: requestEachSeveralPermissionsOneDenied

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test @TargetApi(M) public void requestEachSeveralPermissionsOneDenied() {
  final String[] permissions = { READ_PHONE_STATE, CAMERA };
  doReturn(false).when(rxPermission).isGranted(anyString());
  final int[] result = { PERMISSION_GRANTED, PERMISSION_DENIED };

  final TestObserver<Permission> o = rxPermission.requestEach(permissions)
      .test();

  rxPermission.onRequestPermissionsResult(result, FALSE_ARRAY_2, FALSE_ARRAY_2, permissions);

  o.assertResult(Permission.granted(READ_PHONE_STATE), Permission.deniedNotShown(CAMERA));
}
 
開發者ID:vanniktech,項目名稱:RxPermission,代碼行數:13,代碼來源:RealRxPermissionTest.java

示例9: rx_sumPopulationOfCountries

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_sumPopulationOfCountries() {
    // hint: use "map" operator
    TestObserver<Long> testObserver = countriesService
            .sumPopulationOfCountries(Observable.fromIterable(allCountries), Observable.fromIterable(allCountries))
            .test();
    testObserver.assertResult(CountriesTestProvider.sumPopulationOfAllCountries()
            + CountriesTestProvider.sumPopulationOfAllCountries());
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:11,代碼來源:CountriesServiceSolvedTest.java

示例10: rx_areEmittingSameSequences_Positive

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_areEmittingSameSequences_Positive() {
    // hint: use "sequenceEqual" operator
    TestObserver<Boolean> testObserver = countriesService
            .areEmittingSameSequences(Observable.fromIterable(allCountries), Observable.fromIterable(allCountries))
            .test();
    testObserver.assertResult(true);
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:10,代碼來源:CountriesServiceSolvedTest.java

示例11: rx_areEmittingSameSequences_Negative

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_areEmittingSameSequences_Negative() {
    List<Country> allCountriesDifferentSequence = new ArrayList<>(allCountries);
    Collections.swap(allCountriesDifferentSequence, 0, 1);
    TestObserver<Boolean> testObserver = countriesService
            .areEmittingSameSequences(
                    Observable.fromIterable(allCountries),
                    Observable.fromIterable(allCountriesDifferentSequence))
            .test();
    testObserver.assertResult(false);
    testObserver.assertNoErrors();
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:13,代碼來源:CountriesServiceSolvedTest.java

示例12: requestGranted

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test @TargetApi(M) public void requestGranted() {
  doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);

  final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
      .test();

  rxPermission.onRequestPermissionsResult(permissionGranted(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE);
  o.assertResult(Permission.granted(READ_PHONE_STATE));
}
 
開發者ID:vanniktech,項目名稱:RxPermission,代碼行數:10,代碼來源:RealRxPermissionTest.java

示例13: requestDeniedFirstTime

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test @TargetApi(M) public void requestDeniedFirstTime() {
  doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);

  final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
      .test();

  rxPermission.onRequestPermissionsResult(permissionDenied(), FALSE_ARRAY, TRUE_ARRAY, READ_PHONE_STATE);
  o.assertResult(Permission.denied(READ_PHONE_STATE));
}
 
開發者ID:vanniktech,項目名稱:RxPermission,代碼行數:10,代碼來源:RealRxPermissionTest.java

示例14: requestDeniedAnyOtherTime

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test @TargetApi(M) public void requestDeniedAnyOtherTime() {
  doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);

  final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
      .test();

  rxPermission.onRequestPermissionsResult(permissionDenied(), TRUE_ARRAY, TRUE_ARRAY, READ_PHONE_STATE);
  o.assertResult(Permission.denied(READ_PHONE_STATE));
}
 
開發者ID:vanniktech,項目名稱:RxPermission,代碼行數:10,代碼來源:RealRxPermissionTest.java

示例15: requestDeniedNotShown

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test @TargetApi(M) public void requestDeniedNotShown() {
  doReturn(false).when(rxPermission).isGranted(READ_PHONE_STATE);

  final TestObserver<Permission> o = rxPermission.request(READ_PHONE_STATE)
      .test();

  rxPermission.onRequestPermissionsResult(permissionDenied(), FALSE_ARRAY, FALSE_ARRAY, READ_PHONE_STATE);
  o.assertResult(Permission.deniedNotShown(READ_PHONE_STATE));
}
 
開發者ID:vanniktech,項目名稱:RxPermission,代碼行數:10,代碼來源:RealRxPermissionTest.java


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