Пример #1
0
        public void Commenter_UncommentTest01()
        {
            string original =
                @"
    #x <- 1
x <- 2
";
            ITextView   textView   = TextViewTest.MakeTextView(original, new TextRange(2, 0));
            ITextBuffer textBuffer = textView.TextBuffer;

            var           command = new UncommentCommand(textView, textBuffer, _editorShell);
            CommandStatus status  = command.Status(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.UNCOMMENT_BLOCK);

            status.Should().Be(CommandStatus.SupportedAndEnabled);

            object o = null;

            command.Invoke(Guid.Empty, 0, null, ref o);

            string expected =
                @"
    x <- 1
x <- 2
";

            string actual = textBuffer.CurrentSnapshot.GetText();

            actual.Should().Be(expected);
        }
Пример #2
0
        public void Can_uncomment_lines(string test, int selectionStartLine, int selectionStartColumn, int?selectionEndLine, int?selectionEndColumn, string inputTextValue)
        {
            Console.WriteLine($"running: {test}");
            var command   = new UncommentCommand(null, null, _monitoringService);
            var inputText = new TestText(inputTextValue);
            var textView  = CreateTextView(inputText, selectionStartLine, selectionStartColumn, selectionEndLine, selectionEndColumn);

            command.PreExec(textView, command.Targets.First());

            var expectedText = new TestText(
                "Feature: foo",
                "Scenario: bar",
                "");

            Assert.Equal(expectedText.ToString(), textView.TextSnapshot.GetText());

            AssertLinesSelected(textView, expectedText, selectionStartLine, selectionEndLine);
        }
Пример #3
0
        private void PerformCommand(string commandName, string parameter = null, DeveroomEditorCommandTargetKey?commandTargetKey = null)
        {
            ActionsMock.ResetMock();
            switch (commandName)
            {
            case "Go To Definition":
            {
                var command = new GoToStepDefinitionCommand(_ideScope,
                                                            new StubBufferTagAggregatorFactoryService(_ideScope), _ideScope.MonitoringService);
                command.PreExec(_wpfTextView, command.Targets.First());
                break;
            }

            case "Find Step Definition Usages":
            {
                var command = new FindStepDefinitionCommand(_ideScope,
                                                            new StubBufferTagAggregatorFactoryService(_ideScope), _ideScope.MonitoringService);
                command.PreExec(_wpfTextView, command.Targets.First());
                Wait.For(() => ActionsMock.IsComplete.Should().BeTrue());
                break;
            }

            case "Comment":
            {
                var command = new CommentCommand(_ideScope,
                                                 new StubBufferTagAggregatorFactoryService(_ideScope), _ideScope.MonitoringService);
                command.PreExec(_wpfTextView, command.Targets.First());
                break;
            }

            case "Uncomment":
            {
                var command = new UncommentCommand(_ideScope,
                                                   new StubBufferTagAggregatorFactoryService(_ideScope), _ideScope.MonitoringService);
                command.PreExec(_wpfTextView, command.Targets.First());
                break;
            }

            case "Auto Format Table":
            {
                var command = new AutoFormatTableCommand(_ideScope,
                                                         new StubBufferTagAggregatorFactoryService(_ideScope), _ideScope.MonitoringService);
                _wpfTextView.SimulateType(command, parameter?[0] ?? '|');
                break;
            }

            case "Define Steps":
            {
                var command = new DefineStepsCommand(_ideScope,
                                                     new StubBufferTagAggregatorFactoryService(_ideScope), _ideScope.MonitoringService);
                command.PreExec(_wpfTextView, command.Targets.First());
                break;
            }

            case "Complete":
            case "Filter Completion":
            {
                EnsureStubCompletionBroker();
                var command = new CompleteCommand(_ideScope,
                                                  new StubBufferTagAggregatorFactoryService(_ideScope),
                                                  _completionBroker, _ideScope.MonitoringService);
                if (parameter == null)
                {
                    command.PreExec(_wpfTextView, commandTargetKey ?? command.Targets.First());
                }
                else
                {
                    _wpfTextView.SimulateTypeText(command, parameter);
                }
                break;
            }

            default:
                throw new NotImplementedException(commandName);
            }
        }