@Test
public void TestRemoveObserverWhileNotifying() {

    MockSubject<String> observable = new MockSubject<String>();
    final Disposable subscriptionA = observable.subscribe(new Observer<String>() {
        @Override
        public void onChanged(String value) {
            addResult("A:" + value);
        }
    });
    observable.subscribe(new Observer<String>() {
        @Override
        public void onChanged(String value) {
            addResult("B:" + value);
            subscriptionA.dispose();
        }
    });
    observable.post("1");
    assertResults("A:1", "B:1");
    observable.post("2");
    assertResults("B:2");
}