public void ParseJavaText() { const string originalCode = @"class Klass {}"; var gen = CstGenerators.JavaUsingAntlr3; /*** Code <=> CST ***/ var cst = gen.GenerateTreeFromCodeText(originalCode); Assert.That(cst.Code, Is.EqualTo(originalCode)); // GenerateCodeFromTree() invokes Code Assert.That(gen.GenerateCodeFromTree(cst), Is.EqualTo(originalCode)); /*** CST <=> XML ***/ var xml = cst.ToXml(); Assert.That(CstNode.FromXml(xml).Code, Is.EqualTo(originalCode)); // GenerateXmlFromTree() invokes ToXml() Assert.That( gen.GenerateXmlFromTree(cst).ToString(), Is.EqualTo(xml.ToString())); // GenerateTreeFromXml() invokes CstNode.FromXml() Assert.That( gen.GenerateTreeFromXml(xml).Code, Is.EqualTo(originalCode)); /*** Code <=> XML (via CST) ***/ // GenerateXmlFromCodeText() invokes GenerateTreeFromCodeText() and ToXml() Assert.That( gen.GenerateXmlFromCodeText(originalCode).ToString(), Is.EqualTo(xml.ToString())); // GenerateCodeFromXml() invokes CstNode.FromXml() and Code Assert.That( gen.GenerateCodeFromXml(xml), Is.EqualTo(originalCode)); }