private void verifyComment(CodeFile cf, int lineNum, bool isNonNullOwner, SyntaxEntityKind expectedKind = SyntaxEntityKind.Comment, string expectedName = "") { var node = cf.GetCommentAtLine(lineNum); Assert.AreNotEqual(node, null); if (isNonNullOwner) { Assert.AreEqual(node.Parent.Kind, expectedKind); Assert.AreEqual(node.Parent.Name, expectedName); } else { Assert.AreEqual(node.Parent, null); } }
public void GetCommentTest() { Trace.Listeners.Add(new ConsoleTraceListener()); CSharp lang = new CSharp(); CodeFile cf = lang.Parse(System.IO.File.ReadAllText(@".\Programs\CSharp\ClassWithComments.txt"), @".\Programs\CSharp\ClassWithComments.txt"); //10, 21, 25 verifyComment(cf, 14, true, SyntaxEntityKind.Class, "ClassWithComments"); verifyComment(cf, 16, true, SyntaxEntityKind.Class, "ClassWithComments"); verifyComment(cf, 29, true, SyntaxEntityKind.Function, "Get_I"); verifyComment(cf, 33, true, SyntaxEntityKind.Function, "Square"); verifyComment(cf, 35, true, SyntaxEntityKind.Function, "Square"); var cmt = cf.GetCommentAtLine(38); Assert.AreEqual(cmt, null); }