Skip to content

Commit 4e554d4

Browse files
committed
✨ add StringComparison args to string matchers
1 parent c1b7f8c commit 4e554d4

File tree

8 files changed

+1471
-423
lines changed

8 files changed

+1471
-423
lines changed

src/NExpect.Tests/Exceptions/EnforcingMessage.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ public void ShouldNotThrowWhenMessageContainsOneExpectedFragment()
2323
// Assert
2424
}
2525

26+
[TestFixture]
27+
public class WhenStringComparisonSupplied
28+
{
29+
[Test]
30+
public void ShouldNotThrowWhenMessageContainsOneExpectedFragment()
31+
{
32+
// Arrange
33+
// Act
34+
Assert.That(() =>
35+
{
36+
Expect(() =>
37+
throw new ArgumentException("foo")
38+
).To.Throw<ArgumentException>()
39+
.With.Message.Containing("FOO", StringComparison.OrdinalIgnoreCase);
40+
}, Throws.Nothing);
41+
// Assert
42+
}
43+
}
44+
2645
[Test]
2746
public void ShouldNotThrowWhenMessageContainsTwoExpectedFragments()
2847
{
@@ -47,10 +66,7 @@ public void ShouldNotThrowWhenTwoNegatedAdditions()
4766
var fieldName = GetRandomString(10);
4867
Assert.That(() =>
4968
{
50-
Expect(() =>
51-
{
52-
throw new ArgumentException("NO", fieldName);
53-
})
69+
Expect(() => throw new ArgumentException("NO", fieldName))
5470
.To.Throw<ArgumentException>()
5571
.With.Message.Containing(fieldName)
5672
.And.Not.Containing("{")

0 commit comments

Comments
 (0)