Skip to content

Commit

Permalink
2.x: add fluent requestMore to TestSubscriber (#4838)
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd authored Nov 11, 2016
1 parent bbae4a5 commit 36dde84
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/io/reactivex/subscribers/TestSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

import org.reactivestreams.*;

import io.reactivex.annotations.Experimental;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.internal.fuseable.QueueSubscription;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.*;
import io.reactivex.internal.util.ExceptionHelper;
import io.reactivex.observers.BaseTestConsumer;

/**
Expand Down Expand Up @@ -403,6 +404,18 @@ public final TestSubscriber<T> assertOf(Consumer<? super TestSubscriber<T>> chec
return this;
}

/**
* Calls {@link #request(long)} and returns this.
* @param n the request amount
* @return this
* @since 2.0.1 - experimental
*/
@Experimental
public final TestSubscriber<T> requestMore(long n) {
request(n);
return this;
}

/**
* A subscriber that ignores all events and does not report errors.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/io/reactivex/subscribers/TestSubscriberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1707,4 +1707,16 @@ public void assertValueAtInvalidIndex() {
}
});
}

@Test
public void requestMore() {
Flowable.range(1, 5)
.test(0)
.requestMore(1)
.assertValue(1)
.requestMore(2)
.assertValues(1, 2, 3)
.requestMore(3)
.assertResult(1, 2, 3, 4, 5);
}
}

0 comments on commit 36dde84

Please sign in to comment.