示例#1
0
        public void SourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>(null, System.Linq.Enumerable.Range(0, 10).SelectMany(i => i.Repeat(5)));

            using var query = numbers.ActiveDistinct();
            Assert.AreEqual(0, query.GetElementFaults().Count);
            Assert.AreEqual(10, query.Count);
            numbers.RemoveAt(0);
            Assert.AreEqual(10, query.Count);
            numbers.RemoveRange(0, 4);
            Assert.AreEqual(9, query.Count);
            numbers.Add(10);
            Assert.AreEqual(10, query.Count);
            numbers.AddRange(10.Repeat(4));
            Assert.AreEqual(10, query.Count);
            numbers.Reset(System.Linq.Enumerable.Range(0, 5).SelectMany(i => i.Repeat(2)));
            Assert.AreEqual(5, query.Count);
        }
示例#2
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <int>();

            using var aggregate = numbers.ActiveSum();
            Assert.IsNull(aggregate.OperationFault);
            Assert.AreEqual(0, aggregate.Value);
            numbers.Add(1);
            Assert.IsNull(aggregate.OperationFault);
            Assert.AreEqual(1, aggregate.Value);
            numbers.AddRange(System.Linq.Enumerable.Range(2, 3));
            Assert.AreEqual(10, aggregate.Value);
            numbers.RemoveRange(0, 2);
            Assert.AreEqual(7, aggregate.Value);
            numbers.RemoveAt(0);
            Assert.AreEqual(4, aggregate.Value);
            numbers.Reset(System.Linq.Enumerable.Range(1, 3));
            Assert.AreEqual(6, aggregate.Value);
        }
示例#3
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new SynchronizedRangeObservableCollection <decimal>();

            using var aggregate = numbers.ActiveAverage();
            Assert.IsNotNull(aggregate.OperationFault);
            Assert.AreEqual(0, aggregate.Value);
            numbers.Add(1m);
            Assert.IsNull(aggregate.OperationFault);
            Assert.AreEqual(1m, aggregate.Value);
            numbers.AddRange(System.Linq.Enumerable.Range(2, 3).Select(i => Convert.ToDecimal(i)));
            Assert.AreEqual(2.5m, aggregate.Value);
            numbers.RemoveRange(0, 2);
            Assert.AreEqual(3.5m, aggregate.Value);
            numbers.RemoveAt(0);
            Assert.AreEqual(4m, aggregate.Value);
            numbers.RemoveAt(0);
            Assert.IsNotNull(aggregate.OperationFault);
            Assert.AreEqual(0m, aggregate.Value);
            numbers.Reset(System.Linq.Enumerable.Range(2, 3).Select(i => Convert.ToDecimal(i)));
            Assert.IsNull(aggregate.OperationFault);
            Assert.AreEqual(3m, aggregate.Value);
        }