Пример #1
0
        public void Value_FrozenAfterOnCompleted()
        {
            var s = new BehaviorSubject <int>(42);

            Assert.Equal(42, s.Value);

            Assert.True(s.TryGetValue(out var x));
            Assert.Equal(42, x);

            s.OnNext(43);
            Assert.Equal(43, s.Value);

            Assert.True(s.TryGetValue(out x));
            Assert.Equal(43, x);

            s.OnNext(44);
            Assert.Equal(44, s.Value);

            Assert.True(s.TryGetValue(out x));
            Assert.Equal(44, x);

            s.OnCompleted();
            Assert.Equal(44, s.Value);

            Assert.True(s.TryGetValue(out x));
            Assert.Equal(44, x);

            s.OnNext(1234);
            Assert.Equal(44, s.Value);

            Assert.True(s.TryGetValue(out x));
            Assert.Equal(44, x);
        }
Пример #2
0
        public void Value_First()
        {
            var s = new BehaviorSubject <int>(42);

            Assert.AreEqual(42, s.Value);

            var x = default(int);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(42, x);

            s.OnNext(43);
            Assert.AreEqual(43, s.Value);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(43, x);
        }
Пример #3
0
        public void Value_Initial()
        {
            var s = new BehaviorSubject <int>(42);

            Assert.AreEqual(42, s.Value);

            var x = default(int);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(42, x);
        }
Пример #4
0
        public void Value_Second()
        {
            var s = new BehaviorSubject <int>(42);

            Assert.Equal(42, s.Value);

            Assert.True(s.TryGetValue(out var x));
            Assert.Equal(42, x);

            s.OnNext(43);
            Assert.Equal(43, s.Value);

            Assert.True(s.TryGetValue(out x));
            Assert.Equal(43, x);

            s.OnNext(44);
            Assert.Equal(44, s.Value);

            Assert.True(s.TryGetValue(out x));
            Assert.Equal(44, x);
        }
Пример #5
0
        public void Value_ThrowsOnDispose()
        {
            var s = new BehaviorSubject <int>(42);

            Assert.AreEqual(42, s.Value);

            s.Dispose();

            ReactiveAssert.Throws <ObjectDisposedException>(() =>
            {
                var ignored = s.Value;
            });

            var x = default(int);

            Assert.IsFalse(s.TryGetValue(out x));
        }
Пример #6
0
        public void Value_ThrowsAfterOnError()
        {
            var s = new BehaviorSubject <int>(42);

            Assert.AreEqual(42, s.Value);

            s.OnError(new InvalidOperationException());

            ReactiveAssert.Throws <InvalidOperationException>(() =>
            {
                var ignored = s.Value;
            });

            ReactiveAssert.Throws <InvalidOperationException>(() =>
            {
                var x = default(int);
                s.TryGetValue(out x);
            });
        }
Пример #7
0
 public bool TryGetValue([MaybeNullWhen(false)] out T value)
 => subject.TryGetValue(out value);
Пример #8
0
        public void Value_ThrowsOnDispose()
        {
            var s = new BehaviorSubject<int>(42);
            Assert.AreEqual(42, s.Value);

            s.Dispose();

            ReactiveAssert.Throws<ObjectDisposedException>(() =>
            {
                var ignored = s.Value;
            });

            var x = default(int);
            Assert.IsFalse(s.TryGetValue(out x));
        }
Пример #9
0
        public void Value_ThrowsAfterOnError()
        {
            var s = new BehaviorSubject<int>(42);
            Assert.AreEqual(42, s.Value);

            s.OnError(new InvalidOperationException());

            ReactiveAssert.Throws<InvalidOperationException>(() =>
            {
                var ignored = s.Value;
            });

            ReactiveAssert.Throws<InvalidOperationException>(() =>
            {
                var x = default(int);
                s.TryGetValue(out x);
            });
        }
Пример #10
0
        public void Value_FrozenAfterOnCompleted()
        {
            var s = new BehaviorSubject<int>(42);
            Assert.AreEqual(42, s.Value);

            var x = default(int);
            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(42, x);

            s.OnNext(43);
            Assert.AreEqual(43, s.Value);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(43, x);

            s.OnNext(44);
            Assert.AreEqual(44, s.Value);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(44, x);

            s.OnCompleted();
            Assert.AreEqual(44, s.Value);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(44, x);

            s.OnNext(1234);
            Assert.AreEqual(44, s.Value);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(44, x);
        }
Пример #11
0
        public void Value_Second()
        {
            var s = new BehaviorSubject<int>(42);
            Assert.AreEqual(42, s.Value);

            var x = default(int);
            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(42, x);

            s.OnNext(43);
            Assert.AreEqual(43, s.Value);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(43, x);

            s.OnNext(44);
            Assert.AreEqual(44, s.Value);

            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(44, x);
        }
Пример #12
0
        public void Value_Initial()
        {
            var s = new BehaviorSubject<int>(42);
            Assert.AreEqual(42, s.Value);

            var x = default(int);
            Assert.IsTrue(s.TryGetValue(out x));
            Assert.AreEqual(42, x);
        }
Пример #13
0
        public void Value_First()
        {
            var s = new BehaviorSubject<int>(42);
            Assert.Equal(42, s.Value);

            var x = default(int);
            Assert.True(s.TryGetValue(out x));
            Assert.Equal(42, x);

            s.OnNext(43);
            Assert.Equal(43, s.Value);

            Assert.True(s.TryGetValue(out x));
            Assert.Equal(43, x);
        }