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


Java TestSubscriber.assertResult方法代碼示例

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


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

示例1: testOperator_range

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testOperator_range() {
	TestSubscriber<Long> test_Subscriber = Flowable.rangeLong(10, 5).test();
	test_Subscriber.assertResult(10L, 11L, 12L, 13L, 14L);
	test_Subscriber.assertValueAt(2, (item) -> {
		return item == 12L;
	});

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

示例2: shouldReturnEmojiListForGivenTeam

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldReturnEmojiListForGivenTeam() throws Exception {

    final Team team = TestUtils.createTeam();

    final List<String> emojiList = Arrays.asList("awwyeah", "love", "lol");

    when(emojiRepository.getEmojiList("random uuid")).thenReturn(Single.just(emojiList));

    final TestSubscriber<List<String>> subscriber = new TestSubscriber<>();
    final Single<List<String>> emojiViewModelEmojis = emojiViewModel.getEmojis(team);

    emojiViewModelEmojis.toFlowable().subscribe(subscriber);
    subscriber.assertNoErrors();
    subscriber.assertResult(emojiList);
}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:17,代碼來源:EmojiViewModelTest.java

示例3: shouldReturnTeamsForLoggedInUser

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldReturnTeamsForLoggedInUser() throws Exception {

    final User mockUser = TestUtils.createMockUser();

    List<Team> teams = new ArrayList<>();
    teams.add(new Team("some random uuid", "team A", "photo url"));

    when(userResolver.getLoggedInUser()).thenReturn(mockUser);
    when(teamRepository.getTeams(mockUser)).thenReturn(Single.just(teams));

    final TestSubscriber<List<Team>> testSubscriber = new TestSubscriber<>();
    final Single<List<Team>> listSingle = teamRepository.getTeams(userResolver.getLoggedInUser());


    listSingle.toFlowable().subscribe(testSubscriber);

    testSubscriber.assertNoErrors();
    testSubscriber.assertResult(teams);

}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:22,代碼來源:TeamViewModelTest.java

示例4: shouldReturnUserWhenPassUserNick

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldReturnUserWhenPassUserNick() throws Exception {

    final User user = TestUtils.createMockUser();

    when(userRepository.getUser(user.getNick())).thenReturn(Flowable.just(user));

    final TestSubscriber<User> userTestSubscriber = new TestSubscriber<>();
    final Flowable<User> userByNick = profileViewModel.getUserByNick(user.getNick());
    userByNick.subscribe(userTestSubscriber);

    userTestSubscriber.assertNoErrors();
    userTestSubscriber.assertResult(user);

}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:16,代碼來源:ProfileViewModelTest.java

示例5: shouldReturnValuesFromNonEmptyList

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldReturnValuesFromNonEmptyList() throws Exception {

    final TestScheduler testScheduler = new TestScheduler();
    List<Message> emptyList = Collections.emptyList();

    when(messageCache.getMessages()).thenReturn(Observable.just(emptyList));

    List<Message> apiMessages = new ArrayList<>();
    apiMessages.add(TestUtils.createMessage());

    final Observable<List<Message>> apiObservable = Observable
            .fromArray(apiMessages).delay(10, TimeUnit.SECONDS, testScheduler);

    when(messageRepository.getMessages()).thenReturn(apiObservable);

    final TestSubscriber<List<Message>> userTestSubscriber = new TestSubscriber<>();
    final Observable<List<Message>> messageViewModelMessages = messageViewModel.getMessages();


    messageViewModelMessages.toFlowable(BackpressureStrategy.LATEST)
            .subscribeOn(testScheduler).subscribe(userTestSubscriber);

    userTestSubscriber.assertNoValues();
    userTestSubscriber.assertNotComplete();


    testScheduler.advanceTimeBy(5, TimeUnit.SECONDS);

    userTestSubscriber.assertNoErrors();
    userTestSubscriber.assertValueCount(0);
    testScheduler.advanceTimeBy(5, TimeUnit.SECONDS);
    userTestSubscriber.assertComplete();
    userTestSubscriber.assertValueCount(1);
    userTestSubscriber.assertResult(apiMessages);
}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:37,代碼來源:MessageViewModelTest.java


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