diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs index c9b908831a..042cee2118 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs @@ -14,263 +14,11 @@ namespace XmlEditor.Tests.Utils /// /// Helper class that implements the Text Editor library's IDocument interface. /// - public class MockDocument : IDocument + public class MockDocument { - List lineSegments = new List(); - - public MockDocument() + public static IDocument Create() { + return new DocumentFactory().CreateDocument(); } - - public event EventHandler UpdateCommited; - - public event DocumentEventHandler DocumentAboutToBeChanged; - - public event DocumentEventHandler DocumentChanged; - - public event EventHandler TextContentChanged; - - public void AddLines(string code) - { - int offset = 0; - string[] lines = code.Split('\n'); - foreach (string line in lines) { - int delimiterLength = 1; - if (line.Length > 0 && line[line.Length - 1] == '\r') { - delimiterLength = 2; - } - LineSegment lineSegment = new LineSegment(offset, offset + line.Length, delimiterLength); - lineSegments.Add(lineSegment); - offset += line.Length + lineSegment.DelimiterLength - 1; - } - } - - public ITextEditorProperties TextEditorProperties { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public ICSharpCode.TextEditor.Undo.UndoStack UndoStack { - get { - throw new NotImplementedException(); - } - } - - public bool ReadOnly { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IFormattingStrategy FormattingStrategy { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public ITextBufferStrategy TextBufferStrategy { - get { - throw new NotImplementedException(); - } - } - - public FoldingManager FoldingManager { - get { - throw new NotImplementedException(); - } - } - - public IHighlightingStrategy HighlightingStrategy { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public BookmarkManager BookmarkManager { - get { - throw new NotImplementedException(); - } - } - - public ICustomLineManager CustomLineManager { - get { - throw new NotImplementedException(); - } - } - - public MarkerStrategy MarkerStrategy { - get { - throw new NotImplementedException(); - } - } - - public System.Collections.Generic.List LineSegmentCollection { - get { - return lineSegments; - } - } - - public int TotalNumberOfLines { - get { - if (lineSegments.Count == 0) { - return 1; - } - - return ((LineSegment)lineSegments[lineSegments.Count - 1]).DelimiterLength > 0 ? lineSegments.Count + 1 : lineSegments.Count; - } - } - - public string TextContent { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public int TextLength { - get { - throw new NotImplementedException(); - } - } - - public System.Collections.Generic.List UpdateQueue { - get { - throw new NotImplementedException(); - } - } - - public void UpdateSegmentListOnDocumentChange(System.Collections.Generic.List list, DocumentEventArgs e) where T : ISegment - { - throw new NotImplementedException(); - } - - public int GetLineNumberForOffset(int offset) - { - throw new NotImplementedException(); - } - - public LineSegment GetLineSegmentForOffset(int offset) - { - throw new NotImplementedException(); - } - - public LineSegment GetLineSegment(int lineNumber) - { - return lineSegments[lineNumber]; - } - - public int GetFirstLogicalLine(int lineNumber) - { - throw new NotImplementedException(); - } - - public int GetLastLogicalLine(int lineNumber) - { - throw new NotImplementedException(); - } - - public int GetVisibleLine(int lineNumber) - { - throw new NotImplementedException(); - } - - public int GetNextVisibleLineAbove(int lineNumber, int lineCount) - { - throw new NotImplementedException(); - } - - public int GetNextVisibleLineBelow(int lineNumber, int lineCount) - { - throw new NotImplementedException(); - } - - public void Insert(int offset, string text) - { - throw new NotImplementedException(); - } - - public void Remove(int offset, int length) - { - throw new NotImplementedException(); - } - - public void Replace(int offset, int length, string text) - { - throw new NotImplementedException(); - } - - public char GetCharAt(int offset) - { - throw new NotImplementedException(); - } - - public string GetText(int offset, int length) - { - throw new NotImplementedException(); - } - - public string GetText(ISegment segment) - { - throw new NotImplementedException(); - } - - public System.Drawing.Point OffsetToPosition(int offset) - { - throw new NotImplementedException(); - } - - public int PositionToOffset(System.Drawing.Point p) - { - throw new NotImplementedException(); - } - - public void RequestUpdate(ICSharpCode.TextEditor.TextAreaUpdate update) - { - throw new NotImplementedException(); - } - - public void CommitUpdate() - { - throw new NotImplementedException(); - } - - void OnUpdateCommited() - { - if (UpdateCommited != null) { - } - } - - void OnDocumentAboutToBeChanged() - { - if (DocumentAboutToBeChanged != null) { - } - } - - void OnDocumentChanged() - { - if (DocumentChanged != null) { - } - } - - void OnTextContentChanged() - { - if (TextContentChanged != null) { - } - } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs index c3f9558810..d3716335a2 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs @@ -26,8 +26,8 @@ namespace XmlEditor.Tests.XPathQuery string xml = ""; XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root"); - MockDocument doc = new MockDocument(); - doc.AddLines(xml); + IDocument doc = MockDocument.Create(); + doc.TextContent = xml; MarkerStrategy markerStrategy = new MarkerStrategy(doc); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); @@ -62,8 +62,8 @@ namespace XmlEditor.Tests.XPathQuery string xml = ""; XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()"); - MockDocument doc = new MockDocument(); - doc.AddLines(xml); + IDocument doc = MockDocument.Create(); + doc.TextContent = xml; MarkerStrategy markerStrategy = new MarkerStrategy(doc); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); @@ -89,8 +89,8 @@ namespace XmlEditor.Tests.XPathQuery ""; XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*"); - MockDocument doc = new MockDocument(); - doc.AddLines(xml); + IDocument doc = MockDocument.Create(); + doc.TextContent = xml; MarkerStrategy markerStrategy = new MarkerStrategy(doc); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); diff --git a/src/AddIns/Misc/CodeCoverage/Test/AddCodeCoverageMarkersTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/AddCodeCoverageMarkersTestFixture.cs index 128189db17..528708f235 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/AddCodeCoverageMarkersTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/AddCodeCoverageMarkersTestFixture.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.CodeCoverage.Tests CodeCoverageTextMarker markerOne; CodeCoverageTextMarker markerTwo; CodeCoverageTextMarker markerThree; - MockDocument document; + IDocument document; [TestFixtureSetUp] public void SetUpFixture() @@ -32,11 +32,11 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - document = new MockDocument(); + document = MockDocument.Create(); string code = "\t\t{\r\n" + "\t\t\tint count = 0;\r\n" + "\t\t}\r\n"; - document.AddLines(code); + document.TextContent = code; markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs index 58451f69b7..2e765b368a 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs @@ -27,7 +27,7 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - MockDocument document = new MockDocument(); + IDocument document = MockDocument.Create(); string code = "\t\t{\r\n" + "\t\t\treturn \"\\r\\n\" +\r\n" + "\t\t\t\t\"\\r\\n\" +\r\n" + "\t\t\t\t\"\";\r\n" + "\t\t}\r\n"; - document.AddLines(code); + document.TextContent = code; MarkerStrategy markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverTwoLinesTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverTwoLinesTestFixture.cs index 866cc94628..94817395ed 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverTwoLinesTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverTwoLinesTestFixture.cs @@ -31,12 +31,12 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - MockDocument document = new MockDocument(); + IDocument document = MockDocument.Create(); string code = "\t\t{\r\n" + "\t\t\tAssert.AreEqual(0, childElementCompletionData.Length, \"\" +\r\n" + "\t\t\t \"Not expecting any child elements.\");\r\n" + "\t\t}\r\n"; - document.AddLines(code); + document.TextContent = code; MarkerStrategy markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndColumnTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndColumnTestFixture.cs index b87d9796af..b248e1cb6c 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndColumnTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndColumnTestFixture.cs @@ -28,8 +28,8 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - MockDocument document = new MockDocument(); - document.AddLines("abcdefg\r\nabc"); + IDocument document = MockDocument.Create(); + document.TextContent = "abcdefg\r\nabc"; MarkerStrategy markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndLineTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndLineTestFixture.cs index ffa7271f83..b5d8031ae2 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndLineTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndLineTestFixture.cs @@ -28,9 +28,9 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - MockDocument document = new MockDocument(); + IDocument document = MockDocument.Create(); // Give doc 3 lines (end line seems to be counted as an extra line). - document.AddLines("abc\r\ndef"); + document.TextContent = "abc\r\ndef"; MarkerStrategy markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartColumnTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartColumnTestFixture.cs index 3289b27af3..ff961dbef0 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartColumnTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartColumnTestFixture.cs @@ -28,8 +28,8 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - MockDocument document = new MockDocument(); - document.AddLines("abcdefg\r\nabcdefg"); + IDocument document = MockDocument.Create(); + document.TextContent = "abcdefg\r\nabcdefg"; MarkerStrategy markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartLineTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartLineTestFixture.cs index 37d8e004e5..31987fd387 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartLineTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartLineTestFixture.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - MockDocument document = new MockDocument(); + IDocument document = MockDocument.Create(); MarkerStrategy markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/AddIns/Misc/CodeCoverage/Test/MockDocument.cs b/src/AddIns/Misc/CodeCoverage/Test/MockDocument.cs index c05c41ce81..82a6f3dec2 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/MockDocument.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/MockDocument.cs @@ -14,263 +14,11 @@ namespace ICSharpCode.CodeCoverage.Tests /// /// Helper class that implements the Text Editor library's IDocument interface. /// - public class MockDocument : IDocument + public class MockDocument { - List lineSegments = new List(); - - public MockDocument() + public static IDocument Create() { + return new DocumentFactory().CreateDocument(); } - - public event EventHandler UpdateCommited; - - public event DocumentEventHandler DocumentAboutToBeChanged; - - public event DocumentEventHandler DocumentChanged; - - public event EventHandler TextContentChanged; - - public void AddLines(string code) - { - int offset = 0; - string[] lines = code.Split('\n'); - foreach (string line in lines) { - int delimiterLength = 1; - if (line.Length > 0 && line[line.Length - 1] == '\r') { - delimiterLength = 2; - } - LineSegment lineSegment = new LineSegment(offset, offset + line.Length, delimiterLength); - lineSegments.Add(lineSegment); - offset += line.Length + lineSegment.DelimiterLength - 1; - } - } - - public ITextEditorProperties TextEditorProperties { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public ICSharpCode.TextEditor.Undo.UndoStack UndoStack { - get { - throw new NotImplementedException(); - } - } - - public bool ReadOnly { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IFormattingStrategy FormattingStrategy { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public ITextBufferStrategy TextBufferStrategy { - get { - throw new NotImplementedException(); - } - } - - public FoldingManager FoldingManager { - get { - throw new NotImplementedException(); - } - } - - public IHighlightingStrategy HighlightingStrategy { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public BookmarkManager BookmarkManager { - get { - throw new NotImplementedException(); - } - } - - public ICustomLineManager CustomLineManager { - get { - throw new NotImplementedException(); - } - } - - public MarkerStrategy MarkerStrategy { - get { - throw new NotImplementedException(); - } - } - - public System.Collections.Generic.List LineSegmentCollection { - get { - return lineSegments; - } - } - - public int TotalNumberOfLines { - get { - if (lineSegments.Count == 0) { - return 1; - } - - return ((LineSegment)lineSegments[lineSegments.Count - 1]).DelimiterLength > 0 ? lineSegments.Count + 1 : lineSegments.Count; - } - } - - public string TextContent { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public int TextLength { - get { - throw new NotImplementedException(); - } - } - - public System.Collections.Generic.List UpdateQueue { - get { - throw new NotImplementedException(); - } - } - - public void UpdateSegmentListOnDocumentChange(System.Collections.Generic.List list, DocumentEventArgs e) where T : ISegment - { - throw new NotImplementedException(); - } - - public int GetLineNumberForOffset(int offset) - { - throw new NotImplementedException(); - } - - public LineSegment GetLineSegmentForOffset(int offset) - { - throw new NotImplementedException(); - } - - public LineSegment GetLineSegment(int lineNumber) - { - return lineSegments[lineNumber]; - } - - public int GetFirstLogicalLine(int lineNumber) - { - throw new NotImplementedException(); - } - - public int GetLastLogicalLine(int lineNumber) - { - throw new NotImplementedException(); - } - - public int GetVisibleLine(int lineNumber) - { - throw new NotImplementedException(); - } - - public int GetNextVisibleLineAbove(int lineNumber, int lineCount) - { - throw new NotImplementedException(); - } - - public int GetNextVisibleLineBelow(int lineNumber, int lineCount) - { - throw new NotImplementedException(); - } - - public void Insert(int offset, string text) - { - throw new NotImplementedException(); - } - - public void Remove(int offset, int length) - { - throw new NotImplementedException(); - } - - public void Replace(int offset, int length, string text) - { - throw new NotImplementedException(); - } - - public char GetCharAt(int offset) - { - throw new NotImplementedException(); - } - - public string GetText(int offset, int length) - { - throw new NotImplementedException(); - } - - public string GetText(ISegment segment) - { - throw new NotImplementedException(); - } - - public System.Drawing.Point OffsetToPosition(int offset) - { - throw new NotImplementedException(); - } - - public int PositionToOffset(System.Drawing.Point p) - { - throw new NotImplementedException(); - } - - public void RequestUpdate(ICSharpCode.TextEditor.TextAreaUpdate update) - { - throw new NotImplementedException(); - } - - public void CommitUpdate() - { - throw new NotImplementedException(); - } - - void OnUpdateCommited() - { - if (UpdateCommited != null) { - } - } - - void OnDocumentAboutToBeChanged() - { - if (DocumentAboutToBeChanged != null) { - } - } - - void OnDocumentChanged() - { - if (DocumentChanged != null) { - } - } - - void OnTextContentChanged() - { - if (TextContentChanged != null) { - } - } } } diff --git a/src/AddIns/Misc/CodeCoverage/Test/RemoveCodeCoverageMarkersTestFixture.cs b/src/AddIns/Misc/CodeCoverage/Test/RemoveCodeCoverageMarkersTestFixture.cs index 5c58d56013..bb365e85a9 100644 --- a/src/AddIns/Misc/CodeCoverage/Test/RemoveCodeCoverageMarkersTestFixture.cs +++ b/src/AddIns/Misc/CodeCoverage/Test/RemoveCodeCoverageMarkersTestFixture.cs @@ -28,11 +28,11 @@ namespace ICSharpCode.CodeCoverage.Tests PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); } catch (Exception) {} - MockDocument document = new MockDocument(); + IDocument document = MockDocument.Create(); string code = "\t\t{\r\n" + "\t\t\tint count = 0;\r\n" + "\t\t}\r\n"; - document.AddLines(code); + document.TextContent = code; markerStrategy = new MarkerStrategy(document); string xml = "\r\n" + diff --git a/src/Main/Base/Test/Utils/MockDocument.cs b/src/Main/Base/Test/Utils/MockDocument.cs index fd5def6f8d..f430554c24 100644 --- a/src/Main/Base/Test/Utils/MockDocument.cs +++ b/src/Main/Base/Test/Utils/MockDocument.cs @@ -99,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils } } - public System.Collections.Generic.List LineSegmentCollection { + public System.Collections.Generic.IList LineSegmentCollection { get { throw new NotImplementedException(); }