Skip to content

Instantly share code, notes, and snippets.

@kinjouj
Created July 14, 2015 11:45
Show Gist options
  • Save kinjouj/1bfe48dae9b8707c5710 to your computer and use it in GitHub Desktop.
Save kinjouj/1bfe48dae9b8707c5710 to your computer and use it in GitHub Desktop.
CompositeSubscription test
import rx.subscriptions.BooleanSubscription;
import rx.subscriptions.CompositeSubscription;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.*;
public class CompositeSubscriptionTest {
private CompositeSubscription subscriptions;
@Before
public void setUp() {
subscriptions = new CompositeSubscription();
subscriptions.add(new BooleanSubscription());
}
@Test
public void test_unsubscribe() {
assertThat(subscriptions.hasSubscriptions(), is(true));
subscriptions.unsubscribe();
assertThat(subscriptions.hasSubscriptions(), is(false));
subscriptions.add(new BooleanSubscription());
// java.lang.AssertionError
assertThat(subscriptions.hasSubscriptions(), is(true));
}
@Test
public void test_clear() {
assertThat(subscriptions.hasSubscriptions(), is(true));
subscriptions.clear();
assertThat(subscriptions.hasSubscriptions(), is(false));
subscriptions.add(new BooleanSubscription());
assertThat(subscriptions.hasSubscriptions(), is(true));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment