Example #1
0
        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();
        }
Example #2
0
        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();
        }
Example #3
0
        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);
        }
Example #4
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);
        }
Example #5
0
        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);
        }