Browse Source
Xml element end tag now indents to the same level as the opening tag when the return key is pressed. Xml attributes now indent to the same level when the return key is pressed. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5289 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
16 changed files with 923 additions and 29 deletions
@ -0,0 +1,82 @@
@@ -0,0 +1,82 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
||||
using ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Editor |
||||
{ |
||||
[TestFixture] |
||||
public class ElementEndAddedAfterGreaterThanCharTypedTestFixture |
||||
{ |
||||
XmlFormattingStrategy formattingStrategy; |
||||
MockTextEditor textEditor; |
||||
MockTextEditorOptions options; |
||||
AvalonEditDocumentAdapter document; |
||||
TextDocument textDocument; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
formattingStrategy = new XmlFormattingStrategy(); |
||||
|
||||
options = new MockTextEditorOptions(); |
||||
textEditor = new MockTextEditor(); |
||||
textEditor.Options = options; |
||||
|
||||
textDocument = new TextDocument(); |
||||
document = new AvalonEditDocumentAdapter(textDocument, null); |
||||
textEditor.SetDocument(document); |
||||
|
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"\t<child>\r\n" + |
||||
"</root>\r\n"; |
||||
|
||||
// Just typed the '>' character of the <child> element
|
||||
textEditor.Caret.Offset = 16; |
||||
formattingStrategy.FormatLine(textEditor, '>'); |
||||
} |
||||
|
||||
[Test] |
||||
public void ChildEndElementAddedAfterGreaterThanCharTyped() |
||||
{ |
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child></child>\r\n" + |
||||
"</root>\r\n"; |
||||
|
||||
Assert.AreEqual(expectedText, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndentCanBeUndoneInOneStep() |
||||
{ |
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child>\r\n" + |
||||
"</root>\r\n"; |
||||
|
||||
textDocument.UndoStack.Undo(); |
||||
|
||||
Assert.AreEqual(expectedText, textDocument.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void CursorIsJustBeforeEndElementTagAfterLinesFormatted() |
||||
{ |
||||
int newCaretOffset = 16; |
||||
Assert.AreEqual(newCaretOffset, textEditor.Caret.Offset); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
||||
using ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Editor |
||||
{ |
||||
[TestFixture] |
||||
public class IndentChildElementEndTagAfterNewLineTypedTestFixture |
||||
{ |
||||
XmlFormattingStrategy formattingStrategy; |
||||
MockTextEditor textEditor; |
||||
MockTextEditorOptions options; |
||||
MockDocumentLine docLine; |
||||
AvalonEditDocumentAdapter document; |
||||
TextDocument textDocument; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
formattingStrategy = new XmlFormattingStrategy(); |
||||
|
||||
options = new MockTextEditorOptions(); |
||||
textEditor = new MockTextEditor(); |
||||
textEditor.Options = options; |
||||
|
||||
textDocument = new TextDocument(); |
||||
document = new AvalonEditDocumentAdapter(textDocument, null); |
||||
textEditor.SetDocument(document); |
||||
|
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"\t<child>\r\n" + |
||||
"</child>\r\n" + |
||||
"</root>\r\n"; |
||||
|
||||
docLine = new MockDocumentLine(); |
||||
docLine.LineNumber = 3; |
||||
formattingStrategy.IndentLine(textEditor, docLine); |
||||
} |
||||
|
||||
[Test] |
||||
public void ChildEndElementIndentedBySameLevelAsStartElementAfterNewLineTyped() |
||||
{ |
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child>\r\n" + |
||||
"\t</child>\r\n" + |
||||
"</root>\r\n"; |
||||
|
||||
Assert.AreEqual(expectedText, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndentCanBeUndoneInOneStep() |
||||
{ |
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child>\r\n" + |
||||
"</child>\r\n" + |
||||
"</root>\r\n"; |
||||
|
||||
textDocument.UndoStack.Undo(); |
||||
|
||||
Assert.AreEqual(expectedText, textDocument.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void CursorIsJustBeforeChildEndElementEndTagAfterIndent() |
||||
{ |
||||
int line = 3; |
||||
int column = 2; |
||||
Location expectedLocation = new Location(column, line); |
||||
Assert.AreEqual(expectedLocation, textEditor.Caret.Position); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,245 @@
@@ -0,0 +1,245 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
||||
using ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Editor |
||||
{ |
||||
[TestFixture] |
||||
public class IndentLinesTests |
||||
{ |
||||
XmlFormattingStrategy formattingStrategy; |
||||
MockTextEditor textEditor; |
||||
MockTextEditorOptions options; |
||||
AvalonEditDocumentAdapter document; |
||||
TextDocument textDocument; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
formattingStrategy = new XmlFormattingStrategy(); |
||||
|
||||
options = new MockTextEditorOptions(); |
||||
textEditor = new MockTextEditor(); |
||||
textEditor.Options = options; |
||||
|
||||
textDocument = new TextDocument(); |
||||
document = new AvalonEditDocumentAdapter(textDocument, null); |
||||
textEditor.SetDocument(document); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndentLinesIndentsChildElement() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<child>\r\n" + |
||||
"</child>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child>\r\n" + |
||||
"\t</child>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 4); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text); |
||||
} |
||||
|
||||
public void IndentLinesIndentsChildElementUsingTextEditorIndentationString() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<child>\r\n" + |
||||
"</child>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
" <child>\r\n" + |
||||
" </child>\r\n" + |
||||
"</root>"; |
||||
|
||||
MockTextEditorOptions options = new MockTextEditorOptions(); |
||||
options.IndentationString = " "; |
||||
textEditor.Options = options; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 4); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndentsChildElementAttributesOnOtherLine() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<child\r\n" + |
||||
"attribute1='1'\r\n" + |
||||
"attribute2='2'>\r\n" + |
||||
"</child>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child\r\n" + |
||||
"\t\tattribute1='1'\r\n" + |
||||
"\t\tattribute2='2'>\r\n" + |
||||
"\t</child>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 6); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndentsChildElementAttributeWithSpacesWhenFirstAttributeOnStartElementLine() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<child attribute1='1'\r\n" + |
||||
"attribute2='2'\r\n" + |
||||
"attribute3='3'>\r\n" + |
||||
"</child>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child attribute1='1'\r\n" + |
||||
"\t attribute2='2'\r\n" + |
||||
"\t attribute3='3'>\r\n" + |
||||
"\t</child>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 6); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndentsChildElementAttributeWithTabsWhenChildElementNameIsLargerThan16Chars() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<verylongchildelementname attribute1='1'\r\n" + |
||||
"attribute2='2'\r\n" + |
||||
"attribute3='3'>\r\n" + |
||||
"</verylongchildelementname>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<verylongchildelementname attribute1='1'\r\n" + |
||||
"\t\tattribute2='2'\r\n" + |
||||
"\t\tattribute3='3'>\r\n" + |
||||
"\t</verylongchildelementname>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 6); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void SingleCommentLineIsIndented() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<!-- abc -->\r\n" + |
||||
"<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<!-- abc -->\r\n" + |
||||
"\t<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 4); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void MultipleLineCommentOnlyHasFirstLineIndented() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<!-- 1st\r\n" + |
||||
"2nd\r\n" + |
||||
"3rd -->\r\n" + |
||||
"<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<!-- 1st\r\n" + |
||||
"2nd\r\n" + |
||||
"3rd -->\r\n" + |
||||
"\t<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 6); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void SingleCDataIsIndented() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<![CDATA[ abc ]]>\r\n" + |
||||
"<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<![CDATA[ abc ]]>\r\n" + |
||||
"\t<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 4); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void MultipleLineCDataOnlyHasFirstLineIndented() |
||||
{ |
||||
document.Text = |
||||
"<root>\r\n" + |
||||
"<![CDATA[ 1st\r\n" + |
||||
"2nd\r\n" + |
||||
"3rd ]]>\r\n" + |
||||
"<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<![CDATA[ 1st\r\n" + |
||||
"2nd\r\n" + |
||||
"3rd ]]>\r\n" + |
||||
"\t<child/>\r\n" + |
||||
"</root>"; |
||||
|
||||
formattingStrategy.IndentLines(textEditor, 1, 6); |
||||
|
||||
Assert.AreEqual(expectedText, document.Text, document.Text); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
||||
using ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Editor |
||||
{ |
||||
[TestFixture] |
||||
public class NoElementEndAddedAfterGreaterThanCharTypedTests |
||||
{ |
||||
XmlFormattingStrategy formattingStrategy; |
||||
MockTextEditor textEditor; |
||||
MockTextEditorOptions options; |
||||
AvalonEditDocumentAdapter document; |
||||
TextDocument textDocument; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
formattingStrategy = new XmlFormattingStrategy(); |
||||
|
||||
options = new MockTextEditorOptions(); |
||||
textEditor = new MockTextEditor(); |
||||
textEditor.Options = options; |
||||
|
||||
textDocument = new TextDocument(); |
||||
document = new AvalonEditDocumentAdapter(textDocument, null); |
||||
textEditor.SetDocument(document); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextNotChangedWhenGreaterThanCharTypedAndChildEndElementAlreadyExists() |
||||
{ |
||||
string text = |
||||
"<root>\r\n" + |
||||
"\t<child></child>\r\n" + |
||||
"</root>\r\n"; |
||||
document.Text = text; |
||||
|
||||
// Just typed the '>' character of the <child> element
|
||||
textEditor.Caret.Offset = 16; |
||||
formattingStrategy.FormatLine(textEditor, '>'); |
||||
|
||||
Assert.AreEqual(text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextNotChangedWhenGreaterThanCharTypedAndChildElementIsEmptyElement() |
||||
{ |
||||
string text = |
||||
"<root>\r\n" + |
||||
"\t<child/>\r\n" + |
||||
"</root>\r\n"; |
||||
document.Text = text; |
||||
|
||||
// Just typed the '>' character of the <child/> element
|
||||
textEditor.Caret.Offset = 17; |
||||
formattingStrategy.FormatLine(textEditor, '>'); |
||||
|
||||
Assert.AreEqual(text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextNotChangedWhenGreaterThanCharTypedForCommentTag() |
||||
{ |
||||
string text = "<!-- a -->"; |
||||
document.Text = text; |
||||
|
||||
// Just typed the '>' character of the comment tag
|
||||
textEditor.Caret.Offset = 10; |
||||
formattingStrategy.FormatLine(textEditor, '>'); |
||||
|
||||
Assert.AreEqual(text, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void TextNotChangedWhenGreaterThanCharTypedForPreProcessingInstruction() |
||||
{ |
||||
string text = "<?xml version=\"1.0\"?>"; |
||||
document.Text = text; |
||||
|
||||
// Just typed the '>' character of the pre-processing instruction
|
||||
textEditor.Caret.Offset = 21; |
||||
formattingStrategy.FormatLine(textEditor, '>'); |
||||
|
||||
Assert.AreEqual(text, document.Text); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
||||
using ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Editor |
||||
{ |
||||
[TestFixture] |
||||
public class SurroundTextWithCommentBlockTestFixture |
||||
{ |
||||
XmlFormattingStrategy formattingStrategy; |
||||
MockTextEditor textEditor; |
||||
MockTextEditorOptions options; |
||||
AvalonEditDocumentAdapter document; |
||||
TextDocument textDocument; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
formattingStrategy = new XmlFormattingStrategy(); |
||||
|
||||
options = new MockTextEditorOptions(); |
||||
textEditor = new MockTextEditor(); |
||||
textEditor.Options = options; |
||||
|
||||
textDocument = new TextDocument(); |
||||
document = new AvalonEditDocumentAdapter(textDocument, null); |
||||
textEditor.SetDocument(document); |
||||
|
||||
textDocument.Text = |
||||
"<root>\r\n" + |
||||
"\t<child></child>\r\n" + |
||||
"</root>"; |
||||
|
||||
int selectionStart = 9; |
||||
int selectionLength = 15; |
||||
textEditor.Select(selectionStart, selectionLength); |
||||
|
||||
formattingStrategy.SurroundSelectionWithComment(textEditor); |
||||
} |
||||
|
||||
[Test] |
||||
public void ChildElementSurroundedByCommentTags() |
||||
{ |
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<!--<child></child>-->\r\n" + |
||||
"</root>"; |
||||
Assert.AreEqual(expectedText, document.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void CallingSurroundSelectionWithCommentRemovesCommentTagsWhenCommentTagsExist() |
||||
{ |
||||
int selectionStart = 14; |
||||
int selectionLength = 2; |
||||
textEditor.Select(selectionStart, selectionLength); |
||||
formattingStrategy.SurroundSelectionWithComment(textEditor); |
||||
|
||||
string expectedText = |
||||
"<root>\r\n" + |
||||
"\t<child></child>\r\n" + |
||||
"</root>"; |
||||
|
||||
Assert.AreEqual(expectedText, document.Text); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
|
||||
namespace XmlEditor.Tests.Utils |
||||
{ |
||||
public class MockDocumentLine : IDocumentLine |
||||
{ |
||||
public MockDocumentLine() |
||||
{ |
||||
} |
||||
|
||||
public int Offset { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int Length { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int EndOffset { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int TotalLength { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int DelimiterLength { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int LineNumber { get; set; } |
||||
|
||||
public string Text { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
|
||||
namespace XmlEditor.Tests.Utils |
||||
{ |
||||
public class MockTextEditorOptions : ITextEditorOptions |
||||
{ |
||||
public MockTextEditorOptions() |
||||
{ |
||||
IndentationString = "\t"; |
||||
} |
||||
|
||||
public string IndentationString { get; set; } |
||||
|
||||
public bool AutoInsertBlockEnd { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool ConvertTabsToSpaces { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int IndentationSize { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int VerticalRulerColumn { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.NRefactory; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MockCaretTests |
||||
{ |
||||
MockCaret caret; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
caret = new MockCaret(); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanSetAndGetCaretOffset() |
||||
{ |
||||
caret.Offset = 3; |
||||
Assert.AreEqual(3, caret.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void InitialCaretOffsetIsMinusOne() |
||||
{ |
||||
Assert.AreEqual(-1, caret.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanGetAndSetCaretPosition() |
||||
{ |
||||
Location location = new Location(3, 2); |
||||
caret.Position = location; |
||||
Assert.AreEqual(location, caret.Position); |
||||
} |
||||
|
||||
[Test] |
||||
public void DefaultCaretPostionIsEmpty() |
||||
{ |
||||
Assert.AreEqual(Location.Empty, caret.Position); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MockDocumentLineTests |
||||
{ |
||||
MockDocumentLine documentLine; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
documentLine = new MockDocumentLine(); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanSetAndGetLineNumberProperty() |
||||
{ |
||||
documentLine.LineNumber = 2; |
||||
Assert.AreEqual(2, documentLine.LineNumber); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MockTextEditorOptionsTests |
||||
{ |
||||
MockTextEditorOptions options; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
options = new MockTextEditorOptions(); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndentationStringIsSingleTabByDefault() |
||||
{ |
||||
Assert.AreEqual("\t", options.IndentationString); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanSetAndGetIndentationString() |
||||
{ |
||||
options.IndentationString = "abc"; |
||||
Assert.AreEqual("abc", options.IndentationString); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue