public void testExploration()
        {
            NodeExpander nodeExpander = new PropertyReflectionNodeExpander();
            TestData testData = new TestData();
            ObjectExplorerImpl explorer = new ObjectExplorerImpl();
            explorer.NodeExpander = nodeExpander;
            Object valueFound = null;
            int depth = 0;
            int? depthFound=null;
            MoveBack up = delegate(Object from, String propertyName, Object to, bool isIndexed)
                 {
                     depth--;
                 };
            MoveAway down = delegate(Object from, String propertyName, Object to, bool isIndexed, int ?index)
            {
                depth++;
                return true;
            };
            OnLeaf leaf = delegate(Object from, String propertyName, Object to, int? index)
            {
                if (propertyName!=null && propertyName.Equals("Greeting") )
                {
                    valueFound = to;
                    depthFound = depth + 1;
                }

            };
            explorer.explore(testData, down, up, leaf);
            Assert.AreEqual(testData.TheSub.TheSubSub.Greeting, valueFound, "expected greeting ");
            Assert.AreEqual(4, depthFound, "expected depth");
        }
 public void testToJsonPropertiesIndexed()
 {
     NodeExpander nodeExpander = new PropertyReflectionNodeExpander();
     TestData testData = new TestData();
     String[] expressions = { "TheSub.TheSubSub.Seasons[1]", "TheSub.TheSubSub.GoodYears[1]" };
     Object[] expectedValues = {  testData.TheSub.TheSubSub.Seasons[1], testData.TheSub.TheSubSub.GoodYears[1] };
     Object2Json o2J = new Object2Json();
     //o2J.OmitMarkAsArrayFunction = true;
     o2J.NodeExpander = nodeExpander;
     o2J.IndentSize = 2;
     String json = o2J.toJson(testData);
     validateJSON(json, expressions, expectedValues, "testToJsonPropertiesIndexed");
 }
 public void testToJsonMany2Ones()
 {
     NodeExpander nodeExpander = new FieldReflectionNodeExpander();
     TestData testData = new TestData();
     String[] expressions = { "sub.subSub.seasons" };
     Object[] expectedValues = { testData.TheSub.TheSubSub.Seasons };
     Object2Json o2J = new Object2Json();
     o2J.NodeExpander = nodeExpander;
     o2J.IndentSize = 2;
     String json = o2J.toJson(testData);
     validateJSON(json, expressions, expectedValues, "testToJsonMany2Ones");
 }
 public void testToJsonProperties()
 {
     NodeExpander nodeExpander = new PropertyReflectionNodeExpander();
     TestData testData = new TestData();
     String[] expressions = { "TheSub.TheSubSub.Greeting", "TheSub.TheSubSub.AgeYears", "TheSub.TheSubSub.HeightMetres" };
     Object[] expectedValues = { testData.TheSub.TheSubSub.Greeting, testData.TheSub.TheSubSub.AgeYears, testData.TheSub.TheSubSub.HeightMetres };
     Object2Json o2J = new Object2Json();
     o2J.NodeExpander = nodeExpander;
     o2J.IndentSize = 2;
     String json = o2J.toJson(testData);
     validateJSON(json, expressions, expectedValues, "testToJsonProperties");
 }
 public void testToJsonFields()
 {
     NodeExpander nodeExpander = new FieldReflectionNodeExpander();
     TestData testData = new TestData();
     String[] expressions = { "theDate." + NodeExpanderConstants.unixEpochTimeMillisFieldName, "sub.subSub.greeting", "sub.subSub.ageYears", "sub.subSub.heightMetres" };
     Object[] expectedValues = { NodeExpanderConstants.extractEpochTimeMillis( testData.TheDate) , testData.TheSub.TheSubSub.Greeting, testData.TheSub.TheSubSub.AgeYears, testData.TheSub.TheSubSub.HeightMetres };
     Object2Json o2J = new Object2Json();
     o2J.NodeExpander = nodeExpander;
     o2J.IndentSize = 2;
     String json = o2J.toJson(testData);
     validateJSON(json, expressions, expectedValues, "testToJsonFields");
 }