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

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

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

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

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

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

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