Browse Source

fixed unit tests

pull/23/head
Siegfried Pammer 14 years ago
parent
commit
51c3a092dd
  1. 4
      src/AddIns/BackendBindings/Scripting/Test/Console/InsertConsoleCompletionDataTestFixture.cs
  2. 12
      src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs
  3. 12
      src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs
  4. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs

4
src/AddIns/BackendBindings/Scripting/Test/Console/InsertConsoleCompletionDataTestFixture.cs

@ -30,10 +30,10 @@ namespace ICSharpCode.Scripting.Tests.Console @@ -30,10 +30,10 @@ namespace ICSharpCode.Scripting.Tests.Console
int startOffset = 4;
int endOffset = 5;
SimpleSelection selection = new SimpleSelection(startOffset, endOffset);
Selection selection = Selection.Create(textEditor.TextArea, startOffset, endOffset);
completionData = new ScriptingConsoleCompletionData("new");
completionData.Complete(textEditor.TextArea, selection, null);
completionData.Complete(textEditor.TextArea, selection.SurroundingSegment, null);
string expectedText =
"abc.new";

12
src/AddIns/BackendBindings/Scripting/Test/Console/ScriptingConsoleTextEditorTests.cs

@ -102,8 +102,8 @@ namespace ICSharpCode.Scripting.Tests.Console @@ -102,8 +102,8 @@ namespace ICSharpCode.Scripting.Tests.Console
avalonEditTextEditor.Text = "te000xt";
int startOffset = 2;
int endOffset = 5;
SimpleSelection expectedSelection = new SimpleSelection(startOffset, endOffset);
avalonEditTextEditor.SelectionStart = expectedSelection.StartOffset;
Selection expectedSelection = Selection.Create(avalonEditTextEditor.TextArea, startOffset, endOffset);
avalonEditTextEditor.SelectionStart = expectedSelection.SurroundingSegment.Offset;
avalonEditTextEditor.SelectionLength = expectedSelection.Length;
// Sanity check.
@ -112,10 +112,10 @@ namespace ICSharpCode.Scripting.Tests.Console @@ -112,10 +112,10 @@ namespace ICSharpCode.Scripting.Tests.Console
AssertSelectionsAreEqual(expectedSelection, consoleTextEditor);
}
void AssertSelectionsAreEqual(SimpleSelection expectedSelection, IScriptingConsoleTextEditor consoleTextEditor)
void AssertSelectionsAreEqual(Selection expectedSelection, IScriptingConsoleTextEditor consoleTextEditor)
{
int selectionLength = consoleTextEditor.SelectionStart + consoleTextEditor.SelectionLength;
SimpleSelection actualSelection = new SimpleSelection(consoleTextEditor.SelectionStart, selectionLength);
int selectionEnd = consoleTextEditor.SelectionStart + consoleTextEditor.SelectionLength;
Selection actualSelection = Selection.Create(avalonEditTextEditor.TextArea, consoleTextEditor.SelectionStart, selectionEnd);
Assert.AreEqual(expectedSelection, actualSelection);
}
@ -126,7 +126,7 @@ namespace ICSharpCode.Scripting.Tests.Console @@ -126,7 +126,7 @@ namespace ICSharpCode.Scripting.Tests.Console
avalonEditTextEditor.TextArea.Caret.Column = 1;
avalonEditTextEditor.SelectionLength = 0;
SimpleSelection expectedSelection = new SimpleSelection(1, 1);
Selection expectedSelection = Selection.Create(avalonEditTextEditor.TextArea, 1, 1);
AssertSelectionsAreEqual(expectedSelection, consoleTextEditor);
}

12
src/AddIns/BackendBindings/WixBinding/Test/Utils/MockTextEditor.cs

@ -21,12 +21,16 @@ namespace WixBinding.Tests.Utils @@ -21,12 +21,16 @@ namespace WixBinding.Tests.Utils
AvalonEditDocumentAdapter documentAdapter;
MockCaret caret = new MockCaret();
Location locationJumpedTo = Location.Empty;
SimpleSelection selection = new SimpleSelection(-1, -1);
Selection selection;
MockTextEditorOptions options = new MockTextEditorOptions();
TextArea textArea;
public MockTextEditor()
{
documentAdapter = new AvalonEditDocumentAdapter(textDocument, null);
textArea = new TextArea();
textArea.Document = textDocument;
selection = Selection.Create(textArea, -1, -1);
}
public event EventHandler SelectionChanged;
@ -103,7 +107,7 @@ namespace WixBinding.Tests.Utils @@ -103,7 +107,7 @@ namespace WixBinding.Tests.Utils
if (selection.IsEmpty) {
return String.Empty;
}
return documentAdapter.GetText(selection.StartOffset, selection.Length);
return documentAdapter.GetText(selection.SurroundingSegment.Offset, selection.Length);
}
set {
throw new NotImplementedException();
@ -130,13 +134,13 @@ namespace WixBinding.Tests.Utils @@ -130,13 +134,13 @@ namespace WixBinding.Tests.Utils
public void Select(int selectionStart, int selectionLength)
{
selection = new SimpleSelection(selectionStart, selectionLength + selectionStart);
selection = Selection.Create(textArea, selectionStart, selectionLength + selectionStart);
}
public void JumpTo(int line, int column)
{
locationJumpedTo = new Location(column, line);
selection = new SimpleSelection(-1, -1);
selection = Selection.Create(textArea, -1, -1);
}
public Location LocationJumpedTo {

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Editing/ChangeDocumentTests.cs

@ -17,11 +17,11 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -17,11 +17,11 @@ namespace ICSharpCode.AvalonEdit.Editing
TextArea textArea = new TextArea();
textArea.Document = new TextDocument("1\n2\n3\n4th line");
textArea.Caret.Offset = 6;
textArea.Selection = new SimpleSelection(3, 6);
textArea.Selection = Selection.Create(textArea, 3, 6);
textArea.Document = new TextDocument("1\n2nd");
Assert.AreEqual(0, textArea.Caret.Offset);
Assert.AreEqual(new TextLocation(1, 1), textArea.Caret.Location);
Assert.AreSame(Selection.Empty, textArea.Selection);
Assert.IsTrue(textArea.Selection.IsEmpty);
}
[Test]
@ -30,11 +30,11 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -30,11 +30,11 @@ namespace ICSharpCode.AvalonEdit.Editing
TextArea textArea = new TextArea();
textArea.Document = new TextDocument("1\n2\n3\n4th line");
textArea.Caret.Offset = 6;
textArea.Selection = new SimpleSelection(3, 6);
textArea.Selection = Selection.Create(textArea, 3, 6);
textArea.Document = null;
Assert.AreEqual(0, textArea.Caret.Offset);
Assert.AreEqual(new TextLocation(1, 1), textArea.Caret.Location);
Assert.AreSame(Selection.Empty, textArea.Selection);
Assert.IsTrue(textArea.Selection.IsEmpty);
}
[Test]

Loading…
Cancel
Save