public void Context_In_Selection_OneBased_EvilCode() { const string inputCode = @" Option Explicit Public _ Sub _ foo() Debug.Print ""foo"" End _ Sub : 'Lame comment! "; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component); using (var state = MockParser.CreateAndParse(vbe.Object)) { var tree = state.GetParseTree(new QualifiedModuleName(component)); var visitor = new SubStmtContextElementCollectorVisitor(); var context = visitor.Visit(tree).First(); var selection = new Selection(4, 1, 11, 8); Assert.IsTrue(selection.Contains(context)); Assert.IsFalse(selection.IsContainedIn(context)); } }
public void Context_Not_In_GetSelection_ZeroBased() { const string inputCode = @" Option Explicit Public Sub foo() Debug.Print ""foo"" End Sub : 'Lame comment! "; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component); var pane = component.CodeModule.CodePane; using (var state = MockParser.CreateAndParse(vbe.Object)) { var tree = state.GetParseTree(new QualifiedModuleName(component)); var visitor = new SubStmtContextElementCollectorVisitor(); var context = visitor.Visit(tree).First(); pane.Selection = new Selection(3, 0, 7, 7); Assert.IsFalse(context.GetSelection().Contains(pane.Selection)); Assert.IsFalse(pane.Selection.IsContainedIn(context)); Assert.IsFalse(pane.Selection.Contains(context)); } }