示例#1
0
        public void CommentsTest()
        {
            Trace.Listeners.Add(new ConsoleTraceListener());

            CSharp   csharp = new CSharp();
            CodeFile cf     = csharp.Parse(System.IO.File.ReadAllText(@".\Programs\CSharp\ClassWithComments.txt"), @".\Programs\CSharp\ClassWithComments.txt");

            var cc = new CommentCollector();

            cf.AcceptVisitor(cc);

            Assert.AreEqual(3, cc.Comments.Count());
            Assert.AreEqual(14, cc.Comments.First().Location.StartLineNumber);
            // this will be the line following the comment
            Assert.AreEqual(17, cc.Comments.First().Location.EndLineNumber);
            Assert.AreEqual(SyntaxEntityKind.Class, cc.Comments.First().Parent.Kind);
            Assert.AreEqual(cf.Children.First().Children.First().AssociatedComment, cc.Comments.First());
        }