public void Uses_indent_of_first_line() { var command = CreateSUT(); var inputText = new TestText( "Feature: foo", "Scenario: bar", "Given table", " | foo | bar |", " | bazbaz | qux | ", "| quux| corge| ", ""); var textView = CreateTextView(inputText); inputText.MoveCaretTo(textView, -2, 0); command.PostExec(textView, '|'); // this does not enter the char itself var expectedText = new TestText( "Feature: foo", "Scenario: bar", "Given table", " | foo | bar |", " | bazbaz | qux |", " | quux | corge |", ""); Assert.Equal(expectedText.ToString(), textView.TextSnapshot.GetText()); }
public void Uses_configured_line_ending() { var command = CreateSUT(); var inputText = new TestText( "Feature: foo", "Scenario: bar", "Given table", " | foo | bar |", " | bazbaz | qux | ", "| quux| corge| ", ""); var configuredNewLine = "\n"; var textView = CreateTextView(inputText, configuredNewLine); textView.StubEditorOptions.ReplicateNewLineCharacterOption = false; textView.StubEditorOptions.NewLineCharacterOption = configuredNewLine; inputText.MoveCaretTo(textView, -2, 0); command.PostExec(textView, '|'); // this does not enter the char itself var expectedText = new TestText( "Feature: foo", "Scenario: bar", "Given table", " | foo | bar |", " | bazbaz | qux |", " | quux | corge |", ""); Assert.Equal(expectedText.ToString(configuredNewLine), textView.TextSnapshot.GetText()); }
public void TestBasicProperties() { TestsObject.AssertEqual(TestFloat, 42.0f, "TestFloat"); TestsObject.AssertEqual(TestDouble, 108.0, "TestDouble"); TestsObject.AssertEqual(TestBool, false, "TestBool"); TestsObject.AssertEqual(TestSByte, 43, "TestSByte"); TestsObject.AssertEqual(TestInt16, 44, "TestInt16"); TestsObject.AssertEqual(TestInt, 42, "TestInt"); TestsObject.AssertEqual(TestInt64, 4815162342108, "TestInt64"); TestsObject.AssertEqual(TestByte, 43, "TestByte"); TestsObject.AssertEqual(TestUInt16, 44, "TestUInt16"); TestsObject.AssertEqual(TestUInt32, 0xc001beef, "TestUInt32"); TestsObject.AssertEqual(TestUInt64, 0xdeadbeefdeadbeef, "TestUInt64"); TestsObject.AssertEqual(TestEnum, PixelFormat.A8R8G8B8, "TestEnum"); TestsObject.AssertEqual(TestEnumCpp, ControllerHand.Special7, "TestEnumCpp"); TestsObject.AssertEqual(TestText.ToString(), "Bork bork bork", "TestText"); TestFloat = -42.0f; TestDouble = -108.0; TestInt = -42; TestInt64 = -4815162342108; TestEnum = PixelFormat.BC4; TestEnumCpp = ControllerHand.AnyHand; TestsObject.AssertEqual(TestFloat, -42.0f, "TestFloat-Write"); TestsObject.AssertEqual(TestDouble, -108.0, "TestDouble-Write"); TestsObject.AssertEqual(TestInt, -42, "TestInt-Write"); TestsObject.AssertEqual(TestInt64, -4815162342108, "TestInt64-Write"); TestsObject.AssertEqual(TestEnum, PixelFormat.BC4, "TestEnum-Write"); TestsObject.AssertEqual(TestEnumCpp, ControllerHand.AnyHand, "TestEnumCpp-Write"); TestsObject.AssertEqual(TestPropertyInitializer, 5, "TestPropertyInitializer"); TestsObject.AssertEqual(TestGetOnlyPropertyInitializer, true, "TestGetOnlyPropertyInitializer"); }
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); }
protected IWpfTextView CreateTextView(TestText inputText, int selectionStartLine, int selectionStartColumn, int?selectionEndLine, int?selectionEndColumn) { var textBuffer = VsxStubObjects.CreateTextBuffer(inputText.ToString()); IWpfTextView textView = new StubWpfTextView(textBuffer); if (selectionEndColumn != null && selectionEndLine != null) { textView.Selection.Select(new SnapshotSpan( inputText.GetSnapshotPoint(textView.TextSnapshot, selectionStartLine, selectionStartColumn), inputText.GetSnapshotPoint(textView.TextSnapshot, selectionEndLine.Value, selectionEndColumn.Value)), false); } int caretLine = selectionEndLine ?? selectionStartLine; int caretColumn = selectionEndColumn ?? selectionStartColumn; textView.Caret.MoveTo(inputText.GetSnapshotPoint(textView.TextSnapshot, caretLine, caretColumn)); return(textView); }
public void Should_not_remove_unfinished_cells_when_formattig_table() { var command = CreateSUT(); var inputText = new TestText( @"Feature: foo", @"Scenario: bar", @"Given table", @" | foo | bar ", @" | foo | bar baz ", @" | foo ", @" | ", @" | foo | ", @" | foo | \| ", @" | foo | \|", @" | foo | bar \\| ", @" | foo | bar ", @""); var textView = CreateTextView(inputText); inputText.MoveCaretTo(textView, -2, -1); textView.SimulateType(command, '|'); var expectedText = new TestText( @"Feature: foo", @"Scenario: bar", @"Given table", @" | foo | bar", @" | foo | bar baz", @" | foo", @" |", @" | foo |", @" | foo | \|", @" | foo | \|", @" | foo | bar \\ |", @" | foo | bar |", @""); Assert.Equal(expectedText.ToString(), textView.TextSnapshot.GetText()); }
public void Formats_data_table_when_pipe_typed_of_an_incomplete_table() { var command = CreateSUT(); var inputText = _unformattedText.Replace(-2, @"| c\n\| |"); // remove last cell var textView = CreateTextView(inputText); inputText.MoveCaretTo(textView, -2, -1); textView.SimulateType(command, '|'); var expectedText = new TestText( @"Feature: foo", @"Scenario: bar", @"Given table", @" | foo | bar |", @" | bazbaz | qux |", @" | qu\\ |", @""); Assert.Equal(expectedText.ToString(), textView.TextSnapshot.GetText()); }
public void ThenTheEditorShouldBeUpdatedTo(string expectedContentValue) { var expectedContent = new TestText(expectedContentValue); Assert.Equal(expectedContent.ToString(), _wpfTextView.TextSnapshot.GetText()); }