public void Switch() { var s = new UnicastSubject <ICompletableSource>(); var cs1 = new CompletableSubject(); var cs2 = new CompletableSubject(); var cs3 = new CompletableSubject(); var to = s .SwitchMap(v => v) .Test(); to.AssertEmpty(); Assert.False(cs1.HasObserver()); Assert.False(cs2.HasObserver()); Assert.False(cs3.HasObserver()); s.OnNext(cs1); Assert.True(cs1.HasObserver()); Assert.False(cs2.HasObserver()); Assert.False(cs3.HasObserver()); cs1.OnCompleted(); Assert.False(cs2.HasObserver()); Assert.False(cs3.HasObserver()); s.OnNext(cs2); Assert.True(cs2.HasObserver()); Assert.False(cs3.HasObserver()); s.OnNext(cs3); Assert.False(cs2.HasObserver()); Assert.True(cs3.HasObserver()); to.AssertEmpty(); s.OnCompleted(); to.AssertEmpty(); cs3.OnCompleted(); to.AssertResult(); }