Skip to content

Commit 3a94cbc

Browse files
committed
Update EQualTo constraint with strings with example on IgnoreWhiteSpace
1 parent 35c559e commit 3a94cbc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/snippets/Snippets.NUnit/ConstraintExamples.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ public void EqualConstraint_FloatingPoint()
3838
[Test]
3939
public void EqualConstraint_Strings()
4040
{
41-
Assert.That("Hello!", Is.Not.EqualTo("HELLO!"));
42-
Assert.That("Hello!", Is.EqualTo("HELLO!").IgnoreCase);
41+
string hello = "Hello!";
42+
Assert.That(hello, Is.Not.EqualTo("HELLO!"));
43+
Assert.That(hello, Is.EqualTo("HELLO!").IgnoreCase); // Ignores case in both actual and expected before comparing
4344

4445
string[] expected = ["Hello", "World"];
4546
string[] actual = ["HELLO", "world"];
4647
Assert.That(actual, Is.EqualTo(expected).IgnoreCase);
47-
Assert.That("Hello my world is \r\n on fire!", Is.EqualTo("Hellomy world \r\n is on fire!").IgnoreWhiteSpace);
48+
string actualiws = "Hello my world is \r\n on fire!";
49+
string expectediws = "Hellomy world \r\n is on fire!";
50+
Assert.That(actualiws, Is.EqualTo(expectediws).IgnoreWhiteSpace); // Ignores white space in both actual and expected before comparing
4851
}
4952
#endregion
5053

0 commit comments

Comments
 (0)