Inheritance: Microsoft.Languages.Editor.Controller.Command.EditingCommand
示例#1
0
        public void FormatOnPasteStatus() {
            ITextBuffer textBuffer = new TextBufferMock(string.Empty, RContentTypeDefinition.ContentType);
            ITextView textView = new TextViewMock(textBuffer);
            var clipboard = new ClipboardDataProvider();

            using (var command = new FormatOnPasteCommand(textView, textBuffer, _editorShell)) {
                command.ClipboardDataProvider = clipboard;

                var status = command.Status(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Paste);
                status.Should().Be(CommandStatus.NotSupported);

                clipboard.Format = DataFormats.UnicodeText;
                clipboard.Data = "data";

                status = command.Status(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Paste);
                status.Should().Be(CommandStatus.SupportedAndEnabled);
            }
        }
示例#2
0
        private string FormatFromClipboard(string content) {
            ITextBuffer textBuffer = new TextBufferMock(string.Empty, RContentTypeDefinition.ContentType);
            ITextView textView = new TextViewMock(textBuffer);
            var clipboard = new ClipboardDataProvider();

            using (var command = new FormatOnPasteCommand(textView, textBuffer, _editorShell)) {
                command.ClipboardDataProvider = clipboard;

                clipboard.Format = DataFormats.UnicodeText;
                clipboard.Data = content;

                var ast = RParser.Parse(textBuffer.CurrentSnapshot.GetText());
                using (var document = new EditorDocumentMock(new EditorTreeMock(textBuffer, ast))) {
                    object o = new object();
                    command.Invoke(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Paste, null, ref o);
                }
            }

            return textBuffer.CurrentSnapshot.GetText();
        }