@@ -96,9 +96,9 @@ <h2 id="syntax">Syntax</h2>
96
96
Is.Zero // Equivalent to Is.EqualTo(0)
97
97
</ code > </ pre >
98
98
< h2 id ="modifiers "> Modifiers</ h2 >
99
- < pre > < code class ="lang-csharp "> ...IgnoreCase
99
+ < pre > < code class ="lang-csharp "> ...AsCollection
100
+ ...IgnoreCase
100
101
...IgnoreWhiteSpace // From version 4.2
101
- ...AsCollection
102
102
...NoClip
103
103
...WithSameOffset
104
104
...Within(object tolerance)
@@ -110,8 +110,7 @@ <h2 id="modifiers">Modifiers</h2>
110
110
.Seconds
111
111
.Milliseconds
112
112
.Ticks
113
- ...IgnoreCase
114
- ...IgnoreWhiteSpace
113
+
115
114
...Using(IEqualityComparer comparer)
116
115
...Using(IComparer comparer)
117
116
...Using<T>(IEqualityComparer<T> comparer)
@@ -159,12 +158,16 @@ <h2 id="comparing-numerics">Comparing Numerics</h2>
159
158
< pre > < code class ="lang-csharp " name ="EqualConstraintStrings "> [Test]
160
159
public void EqualConstraint_Strings()
161
160
{
162
- Assert.That("Hello!", Is.Not.EqualTo("HELLO!"));
163
- Assert.That("Hello!", Is.EqualTo("HELLO!").IgnoreCase);
161
+ string hello = "Hello!";
162
+ Assert.That(hello, Is.Not.EqualTo("HELLO!"));
163
+ Assert.That(hello, Is.EqualTo("HELLO!").IgnoreCase); // Ignores case in both actual and expected before comparing
164
164
165
165
string[] expected = ["Hello", "World"];
166
166
string[] actual = ["HELLO", "world"];
167
167
Assert.That(actual, Is.EqualTo(expected).IgnoreCase);
168
+ string actualiws = "Hello my world is \r\n on fire!";
169
+ string expectediws = "Hellomy world \r\n is on fire!";
170
+ Assert.That(actualiws, Is.EqualTo(expectediws).IgnoreWhiteSpace); // Ignores white space in both actual and expected before comparing
168
171
}
169
172
</ code > </ pre >
170
173
< p > Sometimes we need to compare strings irrespective of white space characters, e.g.: when comparing Json strings.
@@ -200,6 +203,7 @@ <h2 id="comparing-numerics">Comparing Numerics</h2>
200
203
------------------------------------------------------^
201
204
</ code > </ pre >
202
205
< p > The < code > IgnoreWhiteSpace</ code > can also be specified when comparing collections of strings.</ p >
206
+ < p > The characters ignored are the same as for the C# < code > Char.IsWhiteSpace</ code > .</ p >
203
207
< h2 id ="comparing-datetimes-and-timespans "> Comparing DateTimes and TimeSpans</ h2 >
204
208
< p > < strong > DateTimes</ strong > and < strong > TimeSpans</ strong > may be compared either with or without a tolerance. A tolerance is specified using
205
209
< strong > Within</ strong > with either a < strong > TimeSpan</ strong > as an argument or with a numeric value followed by a one of the time conversion
@@ -213,7 +217,7 @@ <h2 id="comparing-datetimes-and-timespans">Comparing DateTimes and TimeSpans</h2
213
217
Assert.That(later, Is.EqualTo(now).Within(TimeSpan.FromHours(3.0));
214
218
Assert.That(later, Is.EqualTo(now).Within(3).Hours);
215
219
</ code > </ pre >
216
- < h2 id ="comparing-arrays-collections-and-ienumerables "> Comparing Arrays, Collections and IEnumerables</ h2 >
220
+ < h2 id ="comparing-arrays-collections-and-ienumerables-with-ascollection "> Comparing Arrays, Collections and IEnumerables with AsCollection </ h2 >
217
221
< p > Since version 2.2, NUnit has been able to compare two single-dimensioned arrays. Beginning with version 2.4,
218
222
multi-dimensioned arrays, nested arrays (arrays of arrays) and collections may be compared. With version 2.5, any
219
223
IEnumerable is supported. Two arrays, collections or IEnumerables are considered equal if they have the same dimensions
0 commit comments