示例#1
0
文件: AnyTest.cs 项目: mlessmann/NMF
        public void LambdaAny_ObservableSource_NoUpdateWhenDetached()
        {
            var update = false;
            var coll   = new NotifyCollection <int>()
            {
                -1, -2
            };

            var test = Observable.Expression(() => coll.Any(i => i > 0));

            test.ValueChanged += (o, e) => update = true;

            Assert.IsFalse(test.Value);
            Assert.IsFalse(update);

            test.Detach();

            coll.Add(1);

            Assert.IsFalse(update);

            test.Attach();

            Assert.IsTrue(update);
            Assert.IsTrue(test.Value);
            update = false;

            coll.Remove(1);

            Assert.IsTrue(update);
        }
示例#2
0
        public void LambdaAny_ObservableSourceReset_Update()
        {
            var update = false;
            var coll   = new NotifyCollection <int>()
            {
                1, 2, 3
            };

            var test = Observable.Expression(() => coll.Any(i => i > 0));

            test.ValueChanged += (o, e) => update = true;

            coll.Clear();

            Assert.IsTrue(update);
        }
示例#3
0
文件: AnyTest.cs 项目: FrederikP/NMF
        public void LambdaAny_ObservableSourceReset_Update()
        {
            var update = false;
            var coll = new NotifyCollection<int>() { 1, 2, 3 };

            var test = Observable.Expression(() => coll.Any(i => i > 0));

            test.ValueChanged += (o, e) => update = true;

            coll.Clear();

            Assert.IsTrue(update);
        }
示例#4
0
文件: AnyTest.cs 项目: FrederikP/NMF
        public void LambdaAny_ObservableSource_NoUpdateWhenDetached()
        {
            var update = false;
            var coll = new NotifyCollection<int>() { -1, -2 };

            var test = Observable.Expression(() => coll.Any(i => i > 0));

            test.ValueChanged += (o, e) => update = true;

            Assert.IsFalse(test.Value);
            Assert.IsFalse(update);

            test.Detach();

            coll.Add(1);

            Assert.IsFalse(update);

            test.Attach();

            Assert.IsTrue(update);
            Assert.IsTrue(test.Value);
            update = false;

            coll.Remove(1);

            Assert.IsTrue(update);
        }