Esempio n. 1
0
        public void ExpressionlessSourceManipulation()
        {
            var numbers = new ObservableDictionary <int, int>(System.Linq.Enumerable.Range(0, 10).ToDictionary(i => i));

            using (var query = numbers.ActiveFirst())
            {
                Assert.IsNull(query.OperationFault);
                Assert.AreEqual(0, query.Value.Value);
                numbers.Remove(0);
                Assert.AreEqual(1, query.Value.Value);
                numbers.Clear();
                Assert.IsNotNull(query.OperationFault);
                Assert.AreEqual(0, query.Value.Value);
                numbers.Add(30, 30);
                Assert.IsNull(query.OperationFault);
                Assert.AreEqual(30, query.Value.Value);
                numbers.Reset(new Dictionary <int, int> {
                    { 15, 15 }
                });
                Assert.IsNull(query.OperationFault);
                Assert.AreEqual(15, query.Value.Value);
                numbers.Remove(15);
                Assert.IsNotNull(query.OperationFault);
                Assert.AreEqual(0, query.Value.Value);
            }
        }
Esempio n. 2
0
        public void ExpressionlessEmptySource()
        {
            var numbers = new ObservableDictionary <int, int>();

            using var query = numbers.ActiveFirst();
            Assert.IsNotNull(query.OperationFault);
            Assert.AreEqual(0, query.Value.Value);
        }
Esempio n. 3
0
        public void SourceManipulation()
        {
            var numbers = new ObservableDictionary <int, int>(Enumerable.Range(0, 10).ToDictionary(i => i));

            using var query = numbers.ActiveFirst((key, value) => value % 3 == 0);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(0, query.Value.Value);
            numbers.Remove(0);
            Assert.AreEqual(3, query.Value.Value);
            numbers.RemoveAll((key, value) => value % 3 == 0);
            Assert.IsNotNull(query.OperationFault);
            Assert.AreEqual(0, query.Value.Value);
            numbers.Add(30, 30);
            Assert.IsNull(query.OperationFault);
            Assert.AreEqual(30, query.Value.Value);
        }