Exemple #1
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);
        }
Exemple #2
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);
        }