@@ -96,9 +96,9 @@ <h2 id="syntax">Syntax</h2>
9696Is.Zero // Equivalent to Is.EqualTo(0)
9797</ code > </ pre >
9898< h2 id ="modifiers "> Modifiers</ h2 >
99- < pre > < code class ="lang-csharp "> ...IgnoreCase
99+ < pre > < code class ="lang-csharp "> ...AsCollection
100+ ...IgnoreCase
100101...IgnoreWhiteSpace // From version 4.2
101- ...AsCollection
102102...NoClip
103103...WithSameOffset
104104...Within(object tolerance)
@@ -110,8 +110,7 @@ <h2 id="modifiers">Modifiers</h2>
110110 .Seconds
111111 .Milliseconds
112112 .Ticks
113- ...IgnoreCase
114- ...IgnoreWhiteSpace
113+
115114...Using(IEqualityComparer comparer)
116115...Using(IComparer comparer)
117116...Using<T>(IEqualityComparer<T> comparer)
@@ -159,12 +158,16 @@ <h2 id="comparing-numerics">Comparing Numerics</h2>
159158< pre > < code class ="lang-csharp " name ="EqualConstraintStrings "> [Test]
160159public void EqualConstraint_Strings()
161160{
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
164164
165165 string[] expected = ["Hello", "World"];
166166 string[] actual = ["HELLO", "world"];
167167 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
168171}
169172</ code > </ pre >
170173< 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>
200203 ------------------------------------------------------^
201204</ code > </ pre >
202205< 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 >
203207< h2 id ="comparing-datetimes-and-timespans "> Comparing DateTimes and TimeSpans</ h2 >
204208< p > < strong > DateTimes</ strong > and < strong > TimeSpans</ strong > may be compared either with or without a tolerance. A tolerance is specified using
205209< 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
213217Assert.That(later, Is.EqualTo(now).Within(TimeSpan.FromHours(3.0));
214218Assert.That(later, Is.EqualTo(now).Within(3).Hours);
215219</ 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 >
217221< p > Since version 2.2, NUnit has been able to compare two single-dimensioned arrays. Beginning with version 2.4,
218222multi-dimensioned arrays, nested arrays (arrays of arrays) and collections may be compared. With version 2.5, any
219223IEnumerable is supported. Two arrays, collections or IEnumerables are considered equal if they have the same dimensions
0 commit comments