private void RunGotoDefTestUserDefinedItem(string content, int startLineNumber, int startColumn, int finalCaretPosition) { TextViewMock tv = SetupTextView(content, startLineNumber, startColumn); var cmd = new GoToDefinitionCommand(tv, tv.TextBuffer, Substitute.For <IObjectViewer>(), Substitute.For <IRSession>()); var o = new object(); var result = cmd.Invoke(typeof(VSConstants.VSStd97CmdID).GUID, (int)VSConstants.VSStd97CmdID.GotoDefn, null, ref o); result.Should().Be(CommandResult.Executed); tv.Caret.Position.BufferPosition.Position.Should().Be(finalCaretPosition); }
private void RunGotoDefTest(string content, int startCaretPosition, int finalCaretPosition) { var document = new EditorDocumentMock(content); var tv = new TextViewMock(document.TextBuffer); tv.Caret.MoveTo(new SnapshotPoint(tv.TextBuffer.CurrentSnapshot, startCaretPosition)); var cmd = new GoToDefinitionCommand(tv, document.TextBuffer); var o = new object(); var result = cmd.Invoke(typeof(VSConstants.VSStd97CmdID).GUID, (int)VSConstants.VSStd97CmdID.GotoDefn, null, ref o); result.Should().Be(CommandResult.Executed); tv.Caret.Position.BufferPosition.Position.Should().Be(finalCaretPosition); }
private void RunGotoDefTestInternalItem(string content, int startLineNumber, int startColumn, string itemName) { TextViewMock tv = SetupTextView(content, startLineNumber, startColumn); var session = Substitute.For <IRSession>(); var viewer = Substitute.For <IObjectViewer>(); viewer.ViewObjectDetails(session, REnvironments.GlobalEnv, itemName, itemName).Returns(Task.CompletedTask); var cmd = new GoToDefinitionCommand(tv, tv.TextBuffer, viewer, session); var o = new object(); var result = cmd.Invoke(typeof(VSConstants.VSStd97CmdID).GUID, (int)VSConstants.VSStd97CmdID.GotoDefn, null, ref o); result.Should().Be(CommandResult.Executed); viewer.Received().ViewObjectDetails(session, REnvironments.GlobalEnv, itemName, itemName); }