I've got a method that I'd like to test that looks something like this:
private Disposable getStuff(){
return Observable
.combineLatest(
repoOne.getStuff(),
repoTwo.getOtherStuff(),
session.getSomethingElse(),
session.getOtherSomethingElse(),
(a, b, c, d) -> new Stuff.Builder()
.stuff(a)
.stuffB(b)
.stuffC(c)
.stuffD(d)
.build())
.throttleLast(500, TimeUnit.MILLISECONDS)
.subscribeOn(mSchedulerProvider.io())
.observeOn(mSchedulerProvider.ui())
.subscribe(this::populateStuff, this::showError);
}
I'm trying to test this method but it doesn't get passed throttleLast. I've tried it mostly by applying a TestScheduler, but didn't get anywhere with it. For example I've tried:
<...>
.throttleLast(500, TimeUnit.MILLISECONDS,mTestScheduler)
<...>
Then when I call the method, I advance the time:
mCompositeDisposable.add(getStuff());
mTestScheduler.advanceTimeTo(0, TimeUnit.MILLISECONDS);
mTestScheduler.advanceTimeTo(505, TimeUnit.MILLISECONDS);
But that does nothing, i.e. populateStuff or showError is still not called. I'm probably using the TestScheduler incorrectly, any suggestions?