use of com.amplifyframework.testutils.SimpleCancelable in project amplify-android by aws-amplify.
the class RxAdaptersTest method underlyingOperationIsCanceledWhenSingleSubscriptionIsDisposed.
/**
* {@link CancelableBehaviors#toSingle(CancelableBehaviors.ResultEmitter)}
* returns a {@link Single} which can be canceled. The Amplify {@link Cancelable}
* returned by that emitter will also show as canceled.
*/
@Test
public void underlyingOperationIsCanceledWhenSingleSubscriptionIsDisposed() {
SimpleCancelable cancelable = new SimpleCancelable();
TestObserver<?> observer = CancelableBehaviors.toSingle(((onResult, onError) -> cancelable)).test();
observer.dispose();
assertTrue(observer.isDisposed());
assertTrue(cancelable.isCanceled());
}
use of com.amplifyframework.testutils.SimpleCancelable in project amplify-android by aws-amplify.
the class RxAdaptersTest method underlyingCancelIsCalledWhenObservableSubscriptionIsDisposed.
/**
* The {@link Observable} returned by
* {@link CancelableBehaviors#toObservable(CancelableBehaviors.StreamEmitter)}
* is cancelable.
*/
@Test
public void underlyingCancelIsCalledWhenObservableSubscriptionIsDisposed() {
SimpleCancelable cancelable = new SimpleCancelable();
TestObserver<?> observer = CancelableBehaviors.toObservable((onStart, onItem, onError, onComplete) -> cancelable).test();
observer.dispose();
assertTrue(observer.isDisposed());
assertTrue(cancelable.isCanceled());
}
Aggregations