public void Analyze_ArrayUnclosed_ThrowsAnalyzerException() { // input from fail2.json in test suite at http://www.json.org/JSON_checker/ var input = new [] { ModelGrammar.TokenArrayBeginUnnamed, ModelGrammar.TokenPrimitive("Unclosed array") }; var analyzer = new ModelAnalyzer(new DataReaderSettings()); TokenException <ModelTokenType> ex = Assert.Throws <TokenException <ModelTokenType> >( delegate { var actual = analyzer.Analyze <object>(input).Single(); }); // verify exception is coming from expected token Assert.Equal(ModelGrammar.TokenNone, ex.Token); }
public void Analyze_ObjectUnterminated_ThrowsAnalyzerException() { // input from fail32.json in test suite at http://www.json.org/JSON_checker/ var input = new[] { ModelGrammar.TokenObjectBeginUnnamed, ModelGrammar.TokenProperty("Comma instead if closing brace"), ModelGrammar.TokenTrue }; var analyzer = new ModelAnalyzer(new DataReaderSettings()); TokenException <ModelTokenType> ex = Assert.Throws <TokenException <ModelTokenType> >( delegate { var actual = analyzer.Analyze <object>(input).Single(); }); // verify exception is coming from expected token Assert.Equal(ModelGrammar.TokenNone, ex.Token); }
public void Analyze_ValueInsteadOfProperty_ThrowsAnalyzerException() { // input from fail21.json in test suite at http://www.json.org/JSON_checker/ var input = new[] { ModelGrammar.TokenObjectBeginUnnamed, ModelGrammar.TokenPrimitive("Comma instead of colon"), ModelGrammar.TokenNull, ModelGrammar.TokenObjectEnd }; var analyzer = new ModelAnalyzer(new DataReaderSettings()); TokenException <ModelTokenType> ex = Assert.Throws <TokenException <ModelTokenType> >( delegate { var actual = analyzer.Analyze <object>(input).Single(); }); // verify exception is coming from expected token Assert.Equal(ModelGrammar.TokenPrimitive("Comma instead of colon"), ex.Token); }