Browse Source

Fixed unit tests.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2498 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
c8744453ae
  1. 258
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs
  2. 12
      src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs
  3. 6
      src/AddIns/Misc/CodeCoverage/Test/AddCodeCoverageMarkersTestFixture.cs
  4. 4
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs
  5. 4
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverTwoLinesTestFixture.cs
  6. 4
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndColumnTestFixture.cs
  7. 4
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndLineTestFixture.cs
  8. 4
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartColumnTestFixture.cs
  9. 2
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartLineTestFixture.cs
  10. 258
      src/AddIns/Misc/CodeCoverage/Test/MockDocument.cs
  11. 4
      src/AddIns/Misc/CodeCoverage/Test/RemoveCodeCoverageMarkersTestFixture.cs
  12. 2
      src/Main/Base/Test/Utils/MockDocument.cs

258
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockDocument.cs

@ -14,263 +14,11 @@ namespace XmlEditor.Tests.Utils
/// <summary> /// <summary>
/// Helper class that implements the Text Editor library's IDocument interface. /// Helper class that implements the Text Editor library's IDocument interface.
/// </summary> /// </summary>
public class MockDocument : IDocument public class MockDocument
{ {
List<LineSegment> lineSegments = new List<LineSegment>(); public static IDocument Create()
public MockDocument()
{ {
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<LineSegment> 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<ICSharpCode.TextEditor.TextAreaUpdate> UpdateQueue {
get {
throw new NotImplementedException();
}
}
public void UpdateSegmentListOnDocumentChange<T>(System.Collections.Generic.List<T> 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) {
}
}
} }
} }

12
src/AddIns/DisplayBindings/XmlEditor/Test/XPathQuery/XPathNodeTextMarkerTests.cs

@ -26,8 +26,8 @@ namespace XmlEditor.Tests.XPathQuery
string xml = "<root><foo/></root>"; string xml = "<root><foo/></root>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root"); XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root");
MockDocument doc = new MockDocument(); IDocument doc = MockDocument.Create();
doc.AddLines(xml); doc.TextContent = xml;
MarkerStrategy markerStrategy = new MarkerStrategy(doc); MarkerStrategy markerStrategy = new MarkerStrategy(doc);
XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
@ -62,8 +62,8 @@ namespace XmlEditor.Tests.XPathQuery
string xml = "<!----><root/>"; string xml = "<!----><root/>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()"); XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
MockDocument doc = new MockDocument(); IDocument doc = MockDocument.Create();
doc.AddLines(xml); doc.TextContent = xml;
MarkerStrategy markerStrategy = new MarkerStrategy(doc); MarkerStrategy markerStrategy = new MarkerStrategy(doc);
XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);
@ -89,8 +89,8 @@ namespace XmlEditor.Tests.XPathQuery
"<Xml1></Xml1>"; "<Xml1></Xml1>";
XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*"); XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
MockDocument doc = new MockDocument(); IDocument doc = MockDocument.Create();
doc.AddLines(xml); doc.TextContent = xml;
MarkerStrategy markerStrategy = new MarkerStrategy(doc); MarkerStrategy markerStrategy = new MarkerStrategy(doc);
XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);

6
src/AddIns/Misc/CodeCoverage/Test/AddCodeCoverageMarkersTestFixture.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.CodeCoverage.Tests
CodeCoverageTextMarker markerOne; CodeCoverageTextMarker markerOne;
CodeCoverageTextMarker markerTwo; CodeCoverageTextMarker markerTwo;
CodeCoverageTextMarker markerThree; CodeCoverageTextMarker markerThree;
MockDocument document; IDocument document;
[TestFixtureSetUp] [TestFixtureSetUp]
public void SetUpFixture() public void SetUpFixture()
@ -32,11 +32,11 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
document = new MockDocument(); document = MockDocument.Create();
string code = "\t\t{\r\n" + string code = "\t\t{\r\n" +
"\t\t\tint count = 0;\r\n" + "\t\t\tint count = 0;\r\n" +
"\t\t}\r\n"; "\t\t}\r\n";
document.AddLines(code); document.TextContent = code;
markerStrategy = new MarkerStrategy(document); markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

4
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverMultipleLinesTestFixture.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
MockDocument document = new MockDocument(); IDocument document = MockDocument.Create();
string code = "\t\t{\r\n" + string code = "\t\t{\r\n" +
"\t\t\treturn \"<?xml version=\\\"1.0\\\"?>\\r\\n\" +\r\n" + "\t\t\treturn \"<?xml version=\\\"1.0\\\"?>\\r\\n\" +\r\n" +
"\t\t\t\t\"<xs:schema xmlns:xs=\\\"http://www.w3.org/2001/XMLSchema\\\"\\r\\n\" +\r\n" + "\t\t\t\t\"<xs:schema xmlns:xs=\\\"http://www.w3.org/2001/XMLSchema\\\"\\r\\n\" +\r\n" +
@ -38,7 +38,7 @@ namespace ICSharpCode.CodeCoverage.Tests
"\t\t\t\t\"</xs:element>\\r\\n\" +\r\n" + "\t\t\t\t\"</xs:element>\\r\\n\" +\r\n" +
"\t\t\t\t\"</xs:schema>\";\r\n" + "\t\t\t\t\"</xs:schema>\";\r\n" +
"\t\t}\r\n"; "\t\t}\r\n";
document.AddLines(code); document.TextContent = code;
MarkerStrategy markerStrategy = new MarkerStrategy(document); MarkerStrategy markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

4
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersCoverTwoLinesTestFixture.cs

@ -31,12 +31,12 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
MockDocument document = new MockDocument(); IDocument document = MockDocument.Create();
string code = "\t\t{\r\n" + string code = "\t\t{\r\n" +
"\t\t\tAssert.AreEqual(0, childElementCompletionData.Length, \"\" +\r\n" + "\t\t\tAssert.AreEqual(0, childElementCompletionData.Length, \"\" +\r\n" +
"\t\t\t \"Not expecting any child elements.\");\r\n" + "\t\t\t \"Not expecting any child elements.\");\r\n" +
"\t\t}\r\n"; "\t\t}\r\n";
document.AddLines(code); document.TextContent = code;
MarkerStrategy markerStrategy = new MarkerStrategy(document); MarkerStrategy markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

4
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndColumnTestFixture.cs

@ -28,8 +28,8 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
MockDocument document = new MockDocument(); IDocument document = MockDocument.Create();
document.AddLines("abcdefg\r\nabc"); document.TextContent = "abcdefg\r\nabc";
MarkerStrategy markerStrategy = new MarkerStrategy(document); MarkerStrategy markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

4
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidEndLineTestFixture.cs

@ -28,9 +28,9 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
MockDocument document = new MockDocument(); IDocument document = MockDocument.Create();
// Give doc 3 lines (end line seems to be counted as an extra line). // 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); MarkerStrategy markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

4
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartColumnTestFixture.cs

@ -28,8 +28,8 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
MockDocument document = new MockDocument(); IDocument document = MockDocument.Create();
document.AddLines("abcdefg\r\nabcdefg"); document.TextContent = "abcdefg\r\nabcdefg";
MarkerStrategy markerStrategy = new MarkerStrategy(document); MarkerStrategy markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

2
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageMarkersInvalidStartLineTestFixture.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
MockDocument document = new MockDocument(); IDocument document = MockDocument.Create();
MarkerStrategy markerStrategy = new MarkerStrategy(document); MarkerStrategy markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

258
src/AddIns/Misc/CodeCoverage/Test/MockDocument.cs

@ -14,263 +14,11 @@ namespace ICSharpCode.CodeCoverage.Tests
/// <summary> /// <summary>
/// Helper class that implements the Text Editor library's IDocument interface. /// Helper class that implements the Text Editor library's IDocument interface.
/// </summary> /// </summary>
public class MockDocument : IDocument public class MockDocument
{ {
List<LineSegment> lineSegments = new List<LineSegment>(); public static IDocument Create()
public MockDocument()
{ {
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<LineSegment> 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<ICSharpCode.TextEditor.TextAreaUpdate> UpdateQueue {
get {
throw new NotImplementedException();
}
}
public void UpdateSegmentListOnDocumentChange<T>(System.Collections.Generic.List<T> 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) {
}
}
} }
} }

4
src/AddIns/Misc/CodeCoverage/Test/RemoveCodeCoverageMarkersTestFixture.cs

@ -28,11 +28,11 @@ namespace ICSharpCode.CodeCoverage.Tests
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
} catch (Exception) {} } catch (Exception) {}
MockDocument document = new MockDocument(); IDocument document = MockDocument.Create();
string code = "\t\t{\r\n" + string code = "\t\t{\r\n" +
"\t\t\tint count = 0;\r\n" + "\t\t\tint count = 0;\r\n" +
"\t\t}\r\n"; "\t\t}\r\n";
document.AddLines(code); document.TextContent = code;
markerStrategy = new MarkerStrategy(document); markerStrategy = new MarkerStrategy(document);
string xml = "<coverage>\r\n" + string xml = "<coverage>\r\n" +

2
src/Main/Base/Test/Utils/MockDocument.cs

@ -99,7 +99,7 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils
} }
} }
public System.Collections.Generic.List<LineSegment> LineSegmentCollection { public System.Collections.Generic.IList<LineSegment> LineSegmentCollection {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();
} }

Loading…
Cancel
Save