コード例 #1
0
ファイル: FormatCommandTest.cs プロジェクト: nomada2/RTVS
        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)) {
                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
ファイル: FormatCommandTest.cs プロジェクト: nomada2/RTVS
        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)) {
                command.ClipboardDataProvider = clipboard;

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

                var ast = RParser.Parse(textBuffer.CurrentSnapshot.GetText());
                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();
        }