Exemplo n.º 1
0
        public void TestCodeElementFromPoint()
        {
            var text             = CurrentDocument.GetTextAsync().Result;
            var tree             = CurrentDocument.GetSyntaxTreeAsync().Result;
            var position         = text.ToString().IndexOf("DynamicMethod", StringComparison.Ordinal);
            var virtualTreePoint = new VirtualTreePoint(tree, text, position);
            var textPoint        = new MockTextPoint(virtualTreePoint, 4);
            var scope            = vsCMElement.vsCMElementFunction;
            var element          = CodeModel.CodeElementFromPoint(textPoint, scope);

            Assert.Equal("DynamicMethod", element.Name);
        }
Exemplo n.º 2
0
        public void TestCodeElementFromPointBetweenMembers()
        {
            var text             = CurrentDocument.GetTextAsync().Result;
            var tree             = CurrentDocument.GetSyntaxTreeAsync().Result;
            var position         = text.ToString().IndexOf("protected virtual string MethodB", StringComparison.Ordinal) - 1;
            var virtualTreePoint = new VirtualTreePoint(tree, text, position);
            var textPoint        = new MockTextPoint(virtualTreePoint, 4);

            Assert.Throws <COMException>(() =>
                                         CodeModel.CodeElementFromPoint(textPoint, vsCMElement.vsCMElementFunction));

            var element = CodeModel.CodeElementFromPoint(textPoint, vsCMElement.vsCMElementClass);

            Assert.Equal("A", element.Name);
        }