Created
February 23, 2017 14:13
-
-
Save Adam-Fresko/9f97837bc2ee332e96441a76d21ae55b to your computer and use it in GitHub Desktop.
RxJava with RxAndroid example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Before | |
public void setUp() throws Exception { | |
setupRxSchedulers(); | |
} | |
private void setupRxSchedulers() { | |
RxJavaHooks.setOnIOScheduler(current -> Schedulers.immediate()); | |
RxAndroidPlugins.getInstance().registerSchedulersHook(new RxAndroidSchedulersHook() { | |
@Override | |
public Scheduler getMainThreadScheduler() { | |
return Schedulers.immediate(); // witchout this you would have to use wait in tests | |
} | |
}); | |
} | |
@Test | |
public void testMethod(){ | |
Observable<ArrayList<Object>> placesForLocation = fechObservable(); | |
TestSubscriber<ArrayList<Object>> testSubscriber = new TestSubscriber<>(); | |
placesForLocation.subscribe(testSubscriber); | |
} | |
@After | |
public void tearDown() { | |
RxAndroidPlugins.getInstance().reset(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment