Пример #1
0
        public void SourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(System.Linq.Enumerable.Range(0, 10));

            using var query = numbers.ActiveLast(i => i % 3 == 0);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(9, query.Value);
            numbers.Remove(9);
            Assert.AreEqual(6, query.Value);
            numbers.RemoveAll(i => i % 3 == 0);
            Assert.IsNotNull(query.OperationFault);
            Assert.AreEqual(0, query.Value);
            numbers.Add(30);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(30, query.Value);
        }
Пример #2
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(System.Linq.Enumerable.Range(0, 10));

            using var query = numbers.ActiveFirst();
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(0, query.Value);
            numbers.Remove(0);
            Assert.AreEqual(1, 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);
        }
Пример #3
0
        public void SourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(System.Linq.Enumerable.Range(0, 10));

            using var query = numbers.ActiveElementAtOrDefault(9);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(9, query.Value);
            numbers.Remove(9);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(0, query.Value);
            numbers.Add(30);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(30, query.Value);
            numbers.Insert(9, 15);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(15, query.Value);
        }
Пример #4
0
        public void SourceManipulation()
        {
            var things = new SynchronizedRangeObservableCollection <object>(new object[]
            {
                0,
                false,
                "John",
                DateTime.Now,
                "Emily",
                Guid.NewGuid(),
                "Charles",
                TimeSpan.Zero,
                new object()
            });

            using var strings = things.ActiveOfType <string>();
            void checkStrings(params string[] against) => Assert.IsTrue(strings.OrderBy(s => s).SequenceEqual(against));

            checkStrings("Charles", "Emily", "John");
            things.Add("Bridget");
            things.Remove("John");
            things.Move(things.Count - 1, 0);
            checkStrings("Bridget", "Charles", "Emily");
            things.Reset(new object[]
            {
                new object(),
                TimeSpan.Zero,
                "George",
                Guid.NewGuid(),
                "Craig",
                DateTime.Now,
                "Cliff",
                false,
                0
            });
            checkStrings("Cliff", "Craig", "George");
        }