public void testJsonExplorationParameterised(string json, int expectedStartCount, int expectedEndCount, int expectedLeafCount, LeafEvent[] expectedLeafEvents = null) { Console.WriteLine(String.Format("json: {0}", json)); JSONExplorerImpl jsonExplorerImpl = new JSONExplorerImpl(); ExplorationTestListener etl = new ExplorationTestListener(); jsonExplorerImpl.explore(json, etl); Assert.AreEqual(expectedStartCount, etl.startCount, String.Format("expected {0} object start", expectedStartCount)); Assert.AreEqual(expectedEndCount, etl.endCount, String.Format("expected {0} object end", expectedEndCount)); Assert.AreEqual(expectedLeafCount, etl.leafCount, String.Format("expected {0} leaves", expectedLeafCount)); if (expectedLeafEvents != null) { for (int done = 0; done < expectedLeafEvents.Length; done++) { Assert.AreEqual(expectedLeafEvents[done].propertyName, etl.actualLeafEvents[done].propertyName, String.Format("leaf name {0}", done)); Assert.AreEqual(expectedLeafEvents[done].value, etl.actualLeafEvents[done].value, String.Format("leaf value {0}", done)); Assert.AreEqual(expectedLeafEvents[done].isQuoted, etl.actualLeafEvents[done].isQuoted, String.Format("leaf isQuoted {0} ", done)); } } }
public void testJsonExplorationParameterised(string json, int expectedStartCount, int expectedEndCount, int expectedLeafCount, LeafEvent[] expectedLeafEvents = null) { Console.WriteLine(String.Format("json: {0}", json)); JSONExplorerImpl jsonExplorerImpl = new JSONExplorerImpl(); ExplorationTestListener etl = new ExplorationTestListener(); jsonExplorerImpl.explore(json, etl); Assert.AreEqual(expectedStartCount, etl.startCount, String.Format("expected {0} object start", expectedStartCount)); Assert.AreEqual(expectedEndCount, etl.endCount, String.Format("expected {0} object end", expectedEndCount)); Assert.AreEqual(expectedLeafCount, etl.leafCount, String.Format("expected {0} leaves", expectedLeafCount)); if (expectedLeafEvents!=null) { for ( int done=0; done<expectedLeafEvents.Length; done++) { Assert.AreEqual(expectedLeafEvents[done].propertyName, etl.actualLeafEvents[done].propertyName, String.Format("leaf name {0}", done)); Assert.AreEqual(expectedLeafEvents[done].value, etl.actualLeafEvents[done].value, String.Format("leaf value {0}", done)); Assert.AreEqual(expectedLeafEvents[done].isQuoted, etl.actualLeafEvents[done].isQuoted, String.Format("leaf isQuoted {0} ", done)); } } }