Esempio n. 1
0
        public void GetContextTest()
        {
            Trace.Listeners.Add(new ConsoleTraceListener());
            CSharp   csharp = new CSharp();
            CodeFile cf     = csharp.Parse(System.IO.File.ReadAllText(@".\Programs\CSharp\NestedClasses.txt"), @".\Programs\CSharp\NestedClasses.txt");

            var list = cf.GetContextAtLine(18).ToList();

            Assert.AreEqual(list.Count, 5);
            Assert.AreEqual(list[0].Kind, SyntaxEntityKind.Function);
            Assert.AreEqual(list[0].Name, "Foo");
            Assert.AreEqual(list[1].Kind, SyntaxEntityKind.Class);
            Assert.AreEqual(list[1].Name, "InnerClass");
            Assert.AreEqual(list[2].Kind, SyntaxEntityKind.Class);
            Assert.AreEqual(list[2].Name, "OuterClass");
            Assert.AreEqual(list[3].Kind, SyntaxEntityKind.Namespace);
            Assert.AreEqual(list[3].Name, "Microsoft.CodeTalk.LanguageService.Tests.Programs");
            Assert.AreEqual(list[4].Kind, SyntaxEntityKind.CodeFile);
        }