Exemplo n.º 1
0
        public void ReactiveSubjectBase_Subscribe()
        {
            var s = new MyReactiveSubject <int>();

            var iv2    = default(IReactiveObserver <int>);
            var uri2   = default(Uri);
            var state2 = default(object);

            s.SubscribeImpl = (o, u, x) =>
            {
                iv2    = o;
                uri2   = u;
                state2 = x;

                return(null);
            };

            var iv    = new MyObserver <int>();
            var uri   = new Uri("foo://bar");
            var state = "qux";

            s.Subscribe(iv, uri, state);

            Assert.AreSame(iv, iv2);
            Assert.AreSame(uri, uri2);
            Assert.AreSame(state, state2);
        }
Exemplo n.º 2
0
        public void ReactiveSubjectBase_Subscribe_ArgumentChecking()
        {
            var s = new MyReactiveSubject <int>();

            var iv    = new MyObserver <int>();
            var uri   = new Uri("foo://bar");
            var state = "qux";

            Assert.ThrowsException <ArgumentNullException>(() => s.Subscribe(null, uri, state));
            Assert.ThrowsException <ArgumentNullException>(() => s.Subscribe(iv, null, state));
        }
Exemplo n.º 3
0
        public void ReactiveSubjectBase_OnCompleted()
        {
            var s = new MyReactiveSubject <int>();

            var done = false;

            s.OnCompletedImpl = () => { done = true; };

            s.OnCompleted();

            Assert.IsTrue(done);
        }
Exemplo n.º 4
0
        public void ReactiveSubjectBase_OnNext()
        {
            var s = new MyReactiveSubject <int>();

            var y = 0;

            s.OnNextImpl = (x) => { y = x; };

            s.OnNext(42);

            Assert.AreEqual(42, y);
        }
Exemplo n.º 5
0
        public void ReactiveSubjectBase_Dispose()
        {
            var s = new MyReactiveSubject <int>();

            var disposed = false;

            s.DisposeImpl = () => { disposed = true; };

            s.Dispose();

            Assert.IsTrue(disposed);
        }
Exemplo n.º 6
0
        public void ReactiveSubjectBase_OnError()
        {
            var s = new MyReactiveSubject <int>();

            var err = default(Exception);

            s.OnErrorImpl = (e) => { err = e; };

            var ex = new Exception();

            s.OnError(ex);

            Assert.AreSame(ex, err);
        }
Exemplo n.º 7
0
        public void ReactiveSubjectBase_OnError_ArgumentChecking()
        {
            var s = new MyReactiveSubject <int>();

            Assert.ThrowsException <ArgumentNullException>(() => s.OnError(null));
        }