Пример #1
0
        public void SourceManipulation()
        {
            var numbers = new ObservableDictionary <int, int>(Enumerable.Range(1, 3).ToDictionary(i => i));

            using var expr = numbers.ActiveSingle((key, value) => value % 3 == 0);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(3, expr.Value.Value);
            numbers.Remove(3);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
            numbers.Add(3, 3);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(3, expr.Value.Value);
            numbers.Add(5, 5);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(3, expr.Value.Value);
            numbers.Add(6, 6);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
            numbers.Clear();
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
            numbers.Add(3, 3);
            numbers.Add(6, 6);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
            numbers.Remove(3);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(6, expr.Value.Value);
        }
Пример #2
0
        public void Multiple()
        {
            var numbers = new ObservableDictionary <int, int>(Enumerable.Range(1, 3).ToDictionary(i => i, i => i * 3));

            using var expr = numbers.ActiveSingle((key, value) => value % 3 == 0);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
        }
Пример #3
0
        public void ExpressionlessMultiple()
        {
            var numbers = new ObservableDictionary <int, int>(Enumerable.Range(1, 2).ToDictionary(i => i));

            using var expr = numbers.ActiveSingle();
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
        }
Пример #4
0
        public void ExpressionlessEmptySource()
        {
            var numbers = new ObservableDictionary <int, int>();

            using var expr = numbers.ActiveSingle();
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
        }
Пример #5
0
        public void EmptySource()
        {
            var numbers = new ObservableDictionary <int, int>();

            using (var expr = numbers.ActiveSingle((key, value) => value % 3 == 0))
            {
                Assert.IsNotNull(expr.OperationFault);
                Assert.AreEqual(0, expr.Value.Value);
            }
        }
Пример #6
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new ObservableDictionary <int, int>(Enumerable.Range(1, 1).ToDictionary(i => i));

            using var expr = numbers.ActiveSingle();
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(1, expr.Value.Value);
            numbers.Add(2, 2);
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
            numbers.Remove(1);
            Assert.IsNull(expr.OperationFault);
            Assert.AreEqual(2, expr.Value.Value);
            numbers.Clear();
            Assert.IsNotNull(expr.OperationFault);
            Assert.AreEqual(0, expr.Value.Value);
        }