Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5254 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
3 changed files with 73 additions and 2 deletions
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.Editing |
||||
{ |
||||
[TestFixture] |
||||
public class ChangeDocumentTests |
||||
{ |
||||
[Test] |
||||
public void ClearCaretAndSelectionOnDocumentChange() |
||||
{ |
||||
TextArea textArea = new TextArea(); |
||||
textArea.Document = new TextDocument("1\n2\n3\n4th line"); |
||||
textArea.Caret.Offset = 6; |
||||
textArea.Selection = new SimpleSelection(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); |
||||
} |
||||
|
||||
[Test] |
||||
public void SetDocumentToNull() |
||||
{ |
||||
TextArea textArea = new TextArea(); |
||||
textArea.Document = new TextDocument("1\n2\n3\n4th line"); |
||||
textArea.Caret.Offset = 6; |
||||
textArea.Selection = new SimpleSelection(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); |
||||
} |
||||
|
||||
[Test] |
||||
public void CheckEventOrderOnDocumentChange() |
||||
{ |
||||
TextArea textArea = new TextArea(); |
||||
TextDocument newDocument = new TextDocument(); |
||||
StringBuilder b = new StringBuilder(); |
||||
textArea.TextView.DocumentChanged += delegate { |
||||
b.Append("TextView.DocumentChanged;"); |
||||
Assert.AreSame(newDocument, textArea.TextView.Document); |
||||
Assert.AreSame(newDocument, textArea.Document); |
||||
}; |
||||
textArea.DocumentChanged += delegate { |
||||
b.Append("TextArea.DocumentChanged;"); |
||||
Assert.AreSame(newDocument, textArea.TextView.Document); |
||||
Assert.AreSame(newDocument, textArea.Document); |
||||
}; |
||||
textArea.Document = newDocument; |
||||
Assert.AreEqual("TextView.DocumentChanged;TextArea.DocumentChanged;", b.ToString()); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue