public void Subscribe_CanBeCalledFromOnCompleted() { // Arrange var updateSource = new AsyncUpdateSource(); var observer = Substitute.For <IObserver <float> >(); var subscription = updateSource.Subscribe(observer); observer.When(x => x.OnCompleted()).Do(x => updateSource.Subscribe(observer)); // Act updateSource.OnCompleted(); // Assert observer.Received(1).OnCompleted(); }
public void Dispose_CallsCompleted() { // Arrange var updateSource = new AsyncUpdateSource(); var observer = Substitute.For <IObserver <float> >(); updateSource.Subscribe(observer); // Act updateSource.Dispose(); // Assert observer.Received().OnCompleted(); }
public void OnNext_CallsNext() { // Arrange var updateSource = new AsyncUpdateSource(); var observer = Substitute.For <IObserver <float> >(); updateSource.Subscribe(observer); // Act updateSource.OnNext(0); // Assert observer.Received().OnNext(0); }
public void OnError_CallsError() { // Arrange var updateSource = new AsyncUpdateSource(); var observer = Substitute.For <IObserver <float> >(); var e = new Exception(); updateSource.Subscribe(observer); // Act updateSource.OnError(e); // Assert observer.Received().OnError(e); }
public void Unsubscribe_CanBeCalledFromOnError() { // Arrange var updateSource = new AsyncUpdateSource(); var observer = Substitute.For <IObserver <float> >(); var subscription = updateSource.Subscribe(observer); var e = new Exception(); observer.When(x => x.OnError(e)).Do(x => subscription.Dispose()); // Act updateSource.OnError(e); // Assert observer.Received(1).OnError(e); }