public void GetTokens_GraphCycleTypeMaxDepth_ThrowsGraphCycleException() { var input = new Person { Name = "John, Jr.", Father = new Person { Name = "John, Sr." }, Mother = new Person { Name = "Sally" } }; // create multiple cycles input.Father.Children = input.Mother.Children = new Person[] { input }; var walker = new ModelWalker(new DataWriterSettings { GraphCycles = GraphCycleType.MaxDepth, MaxDepth = 25 }); GraphCycleException ex = Assert.Throws <GraphCycleException>( delegate { walker.GetTokens(input).ToArray(); }); Assert.Equal(GraphCycleType.MaxDepth, ex.CycleType); }
public void GetTokens_GraphCycleTypeMaxDepthFalsePositive_ThrowsGraphCycleException() { // input from fail18.json in test suite at http://www.json.org/JSON_checker/ var input = new[] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { new [] { "Too deep" } } } } } } } } } } } } } } } } } } } }; var walker = new ModelWalker(new DataWriterSettings { GraphCycles = GraphCycleType.MaxDepth, MaxDepth = 19 }); GraphCycleException ex = Assert.Throws <GraphCycleException>( delegate { walker.GetTokens(input).ToArray(); }); Assert.Equal(GraphCycleType.MaxDepth, ex.CycleType); }