本文整理匯總了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;
});
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}