Exemple #1
0
        public void TestDeepTraversal()
        {
            AVObject obj = AVObject.Create("Corgi");
            IDictionary <string, object> someDict = new Dictionary <string, object>()
            {
                { "someList", new List <object>() }
            };

            obj["obj"]      = AVObject.Create("Pug");
            obj["obj2"]     = AVObject.Create("Pug");
            obj["list"]     = new List <object>();
            obj["dict"]     = someDict;
            obj["someBool"] = true;
            obj["someInt"]  = 23;

            IEnumerable <object> traverseResult = AVObjectExtensions.DeepTraversal(obj, true, true);

            Assert.AreEqual(8, traverseResult.Count());

            // Don't traverse beyond the root (since root is AVObject)
            traverseResult = AVObjectExtensions.DeepTraversal(obj, false, true);
            Assert.AreEqual(1, traverseResult.Count());

            traverseResult = AVObjectExtensions.DeepTraversal(someDict, false, true);
            Assert.AreEqual(2, traverseResult.Count());

            // Should ignore root
            traverseResult = AVObjectExtensions.DeepTraversal(obj, true, false);
            Assert.AreEqual(7, traverseResult.Count());
        }