Exemple #1
0
        public void SourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(Enumerable.Range(1, 3));

            using var expr = numbers.ActiveSingle(i => i % 3 == 0);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(3, expr.Value);
            numbers.RemoveAt(2);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value);
            numbers.Add(3);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(3, expr.Value);
            numbers.Add(5);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(3, expr.Value);
            numbers.Add(6);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value);
            numbers.Clear();
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value);
            numbers.Add(3);
            numbers.Add(6);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value);
            numbers.RemoveAt(0);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(6, expr.Value);
        }
Exemple #2
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(System.Linq.Enumerable.Range(0, 10));

            using var query = numbers.ActiveLast();
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(9, query.Value);
            numbers.Remove(9);
            Assert.AreEqual(8, query.Value);
            numbers.Clear();
            Assert.IsNotNull(query.OperationFault);
            Assert.AreEqual(0, query.Value);
            numbers.Add(30);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(30, query.Value);
        }
Exemple #3
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(new int[] { 1 });

            using var expr = numbers.ActiveSingle();
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(1, expr.Value);
            numbers.Add(2);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value);
            numbers.RemoveAt(0);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(2, expr.Value);
            numbers.Clear();
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value);
        }
Exemple #4
0
        public void SourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(Enumerable.Range(1, 10).Select(i => i * 3));

            using var query = numbers.ActiveAll(i => i % 3 == 0);
            Assert.IsNull(query.OperationFault);
            Assert.IsTrue(query.Value);
            numbers[0] = 2;
            Assert.IsFalse(query.Value);
            numbers.RemoveAt(0);
            Assert.IsTrue(query.Value);
            --numbers[0];
            Assert.IsFalse(query.Value);
            numbers.Clear();
            Assert.IsTrue(query.Value);
            numbers.Add(7);
            Assert.IsFalse(query.Value);
        }
Exemple #5
0
        public void NullKeys()
        {
            var john   = new TestPerson(null);
            var people = new SynchronizedRangeObservableCollection <TestPerson>();

            using (var query = people.ToActiveDictionary(p => new KeyValuePair <string, TestPerson>(p.Name, p)))
            {
                Assert.IsNull(query.OperationFault);
                people.Add(john);
                Assert.IsNotNull(query.OperationFault);
                john.Name = "John";
                Assert.IsNull(query.OperationFault);
                john.Name = null;
                Assert.IsNotNull(query.OperationFault);
                people.Clear();
                Assert.IsNull(query.OperationFault);
            }
        }