Esempio n. 1
0
        public void Error()
        {
            var cs = new CompletableSubject();

            Assert.False(cs.HasObserver());
            Assert.False(cs.HasCompleted());
            Assert.False(cs.HasException());
            Assert.IsNull(cs.GetException());

            var to = cs.Test();

            Assert.True(cs.HasObserver());

            to.AssertEmpty();

            var bd = new BooleanDisposable();

            cs.OnSubscribe(bd);
            cs.OnError(new InvalidOperationException());
            cs.OnError(new IndexOutOfRangeException());

            Assert.True(bd.IsDisposed());

            to.AssertFailure(typeof(InvalidOperationException));

            Assert.False(cs.HasObserver());
            Assert.False(cs.HasCompleted());
            Assert.True(cs.HasException());
            Assert.IsNotNull(cs.GetException());
            Assert.True(typeof(InvalidOperationException).IsAssignableFrom(cs.GetException()));

            cs.Test().AssertFailure(typeof(InvalidOperationException));

            Assert.False(cs.HasObserver());
            Assert.False(cs.HasCompleted());
            Assert.True(cs.HasException());
            Assert.IsNotNull(cs.GetException());
            Assert.True(typeof(InvalidOperationException).IsAssignableFrom(cs.GetException()));
        }
Esempio n. 2
0
        public void Basic()
        {
            var cs = new CompletableSubject();

            Assert.False(cs.HasObservers);
            Assert.False(cs.HasCompleted());
            Assert.False(cs.HasException());
            Assert.IsNull(cs.GetException());

            var to = cs.Test();

            Assert.True(cs.HasObserver());

            to.AssertEmpty();

            var bd = new BooleanDisposable();

            cs.OnSubscribe(bd);

            cs.OnCompleted();
            cs.OnError(new IndexOutOfRangeException());

            Assert.True(bd.IsDisposed());

            to.AssertResult();

            Assert.False(cs.HasObservers);
            Assert.True(cs.HasCompleted());
            Assert.False(cs.HasException());
            Assert.IsNull(cs.GetException());

            cs.Test().AssertResult();

            Assert.False(cs.HasObserver());
            Assert.True(cs.HasCompleted());
            Assert.False(cs.HasException());
            Assert.IsNull(cs.GetException());
        }