예제 #1
0
        public void SourceManipulation()
        {
            var numbers = new RangeObservableCollection <int>(System.Linq.Enumerable.Range(1, 3));

            using (var expr = numbers.ActiveSingleOrDefault(i => i % 3 == 0))
            {
                Assert.IsNull(expr.OperationFault);
                Assert.AreEqual(3, expr.Value);
                numbers.RemoveAt(2);
                Assert.IsNull(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.IsNull(expr.OperationFault);
                Assert.AreEqual(0, expr.Value);
            }
        }
예제 #2
0
        public void ExpressionlessMultiple()
        {
            var numbers = new RangeObservableCollection <int>(new int[] { 1, 1 });

            using (var expr = numbers.ActiveSingleOrDefault())
            {
                Assert.IsNotNull(expr.OperationFault);
                Assert.AreEqual(0, expr.Value);
            }
        }
예제 #3
0
        public void ExpressionlessEmptySource()
        {
            var numbers = new RangeObservableCollection <int>();

            using (var expr = numbers.ActiveSingleOrDefault())
            {
                Assert.IsNull(expr.OperationFault);
                Assert.AreEqual(0, expr.Value);
            }
        }
예제 #4
0
        public void Multiple()
        {
            var numbers = new RangeObservableCollection <int>(System.Linq.Enumerable.Range(1, 3).Select(i => i * 3));

            using (var expr = numbers.ActiveSingleOrDefault(i => i % 3 == 0))
            {
                Assert.IsNotNull(expr.OperationFault);
                Assert.AreEqual(0, expr.Value);
            }
        }
예제 #5
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new RangeObservableCollection <int>(new int[] { 1 });

            using (var expr = numbers.ActiveSingleOrDefault())
            {
                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.IsNull(expr.OperationFault);
                Assert.AreEqual(0, expr.Value);
            }
        }