Skip to content

Commit 826314b

Browse files
Merge pull request #438 from icsharpcode/feature/nunit4
Migrate to NUnit4
2 parents bce6a08 + 3a6758a commit 826314b

22 files changed

+560
-562
lines changed

ICSharpCode.AvalonEdit.Tests/Document/ChangeTrackingTest.cs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
using System;
2020
using System.Linq;
21+
2122
using NUnit.Framework;
2223

2324
namespace ICSharpCode.AvalonEdit.Document
@@ -31,12 +32,12 @@ public void NoChanges()
3132
TextDocument document = new TextDocument("initial text");
3233
ITextSource snapshot1 = document.CreateSnapshot();
3334
ITextSource snapshot2 = document.CreateSnapshot();
34-
Assert.AreEqual(0, snapshot1.Version.CompareAge(snapshot2.Version));
35-
Assert.AreEqual(0, snapshot1.Version.GetChangesTo(snapshot2.Version).Count());
36-
Assert.AreEqual(document.Text, snapshot1.Text);
37-
Assert.AreEqual(document.Text, snapshot2.Text);
35+
Assert.That(snapshot1.Version.CompareAge(snapshot2.Version), Is.EqualTo(0));
36+
Assert.That(snapshot1.Version.GetChangesTo(snapshot2.Version).Count(), Is.EqualTo(0));
37+
Assert.That(snapshot1.Text, Is.EqualTo(document.Text));
38+
Assert.That(snapshot2.Text, Is.EqualTo(document.Text));
3839
}
39-
40+
4041
[Test]
4142
public void ForwardChanges()
4243
{
@@ -45,16 +46,16 @@ public void ForwardChanges()
4546
document.Replace(0, 7, "nw");
4647
document.Insert(1, "e");
4748
ITextSource snapshot2 = document.CreateSnapshot();
48-
Assert.AreEqual(-1, snapshot1.Version.CompareAge(snapshot2.Version));
49+
Assert.That(snapshot1.Version.CompareAge(snapshot2.Version), Is.EqualTo(-1));
4950
TextChangeEventArgs[] arr = snapshot1.Version.GetChangesTo(snapshot2.Version).ToArray();
50-
Assert.AreEqual(2, arr.Length);
51-
Assert.AreEqual("nw", arr[0].InsertedText.Text);
52-
Assert.AreEqual("e", arr[1].InsertedText.Text);
53-
54-
Assert.AreEqual("initial text", snapshot1.Text);
55-
Assert.AreEqual("new text", snapshot2.Text);
51+
Assert.That(arr.Length, Is.EqualTo(2));
52+
Assert.That(arr[0].InsertedText.Text, Is.EqualTo("nw"));
53+
Assert.That(arr[1].InsertedText.Text, Is.EqualTo("e"));
54+
55+
Assert.That(snapshot1.Text, Is.EqualTo("initial text"));
56+
Assert.That(snapshot2.Text, Is.EqualTo("new text"));
5657
}
57-
58+
5859
[Test]
5960
public void BackwardChanges()
6061
{
@@ -63,14 +64,14 @@ public void BackwardChanges()
6364
document.Replace(0, 7, "nw");
6465
document.Insert(1, "e");
6566
ITextSource snapshot2 = document.CreateSnapshot();
66-
Assert.AreEqual(1, snapshot2.Version.CompareAge(snapshot1.Version));
67+
Assert.That(snapshot2.Version.CompareAge(snapshot1.Version), Is.EqualTo(1));
6768
TextChangeEventArgs[] arr = snapshot2.Version.GetChangesTo(snapshot1.Version).ToArray();
68-
Assert.AreEqual(2, arr.Length);
69-
Assert.AreEqual("", arr[0].InsertedText.Text);
70-
Assert.AreEqual("initial", arr[1].InsertedText.Text);
71-
72-
Assert.AreEqual("initial text", snapshot1.Text);
73-
Assert.AreEqual("new text", snapshot2.Text);
69+
Assert.That(arr.Length, Is.EqualTo(2));
70+
Assert.That(arr[0].InsertedText.Text, Is.Empty);
71+
Assert.That(arr[1].InsertedText.Text, Is.EqualTo("initial"));
72+
73+
Assert.That(snapshot1.Text, Is.EqualTo("initial text"));
74+
Assert.That(snapshot2.Text, Is.EqualTo("new text"));
7475
}
7576
}
7677
}

ICSharpCode.AvalonEdit.Tests/Document/CollapsingTests.cs

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
// DEALINGS IN THE SOFTWARE.
1818

1919
using System;
20+
2021
using ICSharpCode.AvalonEdit.Rendering;
22+
2123
using NUnit.Framework;
2224

2325
namespace ICSharpCode.AvalonEdit.Document
@@ -27,7 +29,7 @@ public class CollapsingTests
2729
{
2830
TextDocument document;
2931
HeightTree heightTree;
30-
32+
3133
[SetUp]
3234
public void Setup()
3335
{
@@ -38,40 +40,40 @@ public void Setup()
3840
heightTree.SetHeight(line, line.LineNumber);
3941
}
4042
}
41-
43+
4244
CollapsedLineSection SimpleCheck(int from, int to)
4345
{
4446
CollapsedLineSection sec1 = heightTree.CollapseText(document.GetLineByNumber(from), document.GetLineByNumber(to));
4547
for (int i = 1; i < from; i++) {
46-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
48+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
4749
}
4850
for (int i = from; i <= to; i++) {
49-
Assert.IsTrue(heightTree.GetIsCollapsed(i));
51+
Assert.That(heightTree.GetIsCollapsed(i), Is.True);
5052
}
5153
for (int i = to + 1; i <= 10; i++) {
52-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
54+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
5355
}
5456
CheckHeights();
5557
return sec1;
5658
}
57-
59+
5860
[Test]
5961
public void SimpleCheck()
6062
{
6163
SimpleCheck(4, 6);
6264
}
63-
65+
6466
[Test]
6567
public void SimpleUncollapse()
6668
{
6769
CollapsedLineSection sec1 = heightTree.CollapseText(document.GetLineByNumber(4), document.GetLineByNumber(6));
6870
sec1.Uncollapse();
6971
for (int i = 1; i <= 10; i++) {
70-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
72+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
7173
}
7274
CheckHeights();
7375
}
74-
76+
7577
[Test]
7678
public void FullCheck()
7779
{
@@ -80,34 +82,34 @@ public void FullCheck()
8082
try {
8183
SimpleCheck(from, to).Uncollapse();
8284
for (int i = 1; i <= 10; i++) {
83-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
85+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
8486
}
85-
CheckHeights();
87+
CheckHeights();
8688
} catch {
8789
Console.WriteLine("from = " + from + ", to = " + to);
8890
throw;
8991
}
9092
}
9193
}
9294
}
93-
95+
9496
[Test]
9597
public void InsertInCollapsedSection()
9698
{
9799
CollapsedLineSection sec1 = heightTree.CollapseText(document.GetLineByNumber(4), document.GetLineByNumber(6));
98100
document.Insert(document.GetLineByNumber(5).Offset, "a\nb\nc");
99101
for (int i = 1; i < 4; i++) {
100-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
102+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
101103
}
102104
for (int i = 4; i <= 8; i++) {
103-
Assert.IsTrue(heightTree.GetIsCollapsed(i));
105+
Assert.That(heightTree.GetIsCollapsed(i), Is.True);
104106
}
105107
for (int i = 9; i <= 12; i++) {
106-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
108+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
107109
}
108110
CheckHeights();
109111
}
110-
112+
111113
[Test]
112114
public void RemoveInCollapsedSection()
113115
{
@@ -116,17 +118,17 @@ public void RemoveInCollapsedSection()
116118
int line6Offset = document.GetLineByNumber(6).Offset;
117119
document.Remove(line4Offset, line6Offset - line4Offset);
118120
for (int i = 1; i < 3; i++) {
119-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
121+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
120122
}
121123
for (int i = 3; i <= 5; i++) {
122-
Assert.IsTrue(heightTree.GetIsCollapsed(i));
124+
Assert.That(heightTree.GetIsCollapsed(i), Is.True);
123125
}
124126
for (int i = 6; i <= 8; i++) {
125-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
127+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
126128
}
127129
CheckHeights();
128130
}
129-
131+
130132
[Test]
131133
public void RemoveEndOfCollapsedSection()
132134
{
@@ -135,33 +137,33 @@ public void RemoveEndOfCollapsedSection()
135137
int line8Offset = document.GetLineByNumber(8).Offset;
136138
document.Remove(line5Offset, line8Offset - line5Offset);
137139
for (int i = 1; i < 3; i++) {
138-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
140+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
139141
}
140142
for (int i = 3; i <= 5; i++) {
141-
Assert.IsTrue(heightTree.GetIsCollapsed(i));
143+
Assert.That(heightTree.GetIsCollapsed(i), Is.True);
142144
}
143145
for (int i = 6; i <= 7; i++) {
144-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
146+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
145147
}
146148
CheckHeights();
147149
}
148-
150+
149151
[Test]
150152
public void RemoveCollapsedSection()
151153
{
152154
CollapsedLineSection sec1 = heightTree.CollapseText(document.GetLineByNumber(3), document.GetLineByNumber(3));
153155
int line3Offset = document.GetLineByNumber(3).Offset;
154156
document.Remove(line3Offset - 1, 1);
155157
for (int i = 1; i <= 9; i++) {
156-
Assert.IsFalse(heightTree.GetIsCollapsed(i));
158+
Assert.That(heightTree.GetIsCollapsed(i), Is.False);
157159
}
158160
CheckHeights();
159-
Assert.AreSame(null, sec1.Start);
160-
Assert.AreSame(null, sec1.End);
161+
Assert.That(sec1.Start, Is.SameAs(null));
162+
Assert.That(sec1.End, Is.SameAs(null));
161163
// section gets uncollapsed when it is removed
162-
Assert.IsFalse(sec1.IsCollapsed);
164+
Assert.That(sec1.IsCollapsed, Is.False);
163165
}
164-
166+
165167
void CheckHeights()
166168
{
167169
HeightTests.CheckHeights(document, heightTree);

ICSharpCode.AvalonEdit.Tests/Document/HeightTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ internal static void CheckHeights(TextDocument document, HeightTree heightTree)
8383
visualPositions[i+1]=visualPositions[i]+heights[i];
8484
}
8585
foreach (DocumentLine ls in document.Lines) {
86-
Assert.AreEqual(visualPositions[ls.LineNumber-1], heightTree.GetVisualPosition(ls));
86+
Assert.That(heightTree.GetVisualPosition(ls), Is.EqualTo(visualPositions[ls.LineNumber - 1]));
8787
}
88-
Assert.AreEqual(visualPositions[document.LineCount], heightTree.TotalHeight);
88+
Assert.That(heightTree.TotalHeight, Is.EqualTo(visualPositions[document.LineCount]));
8989
}
9090
}
9191
}

0 commit comments

Comments
 (0)