shouldly / shouldly

Should testing for .NET—the way assertions should be!

Home Page:https://docs.shouldly.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ShouldContain throws exception on null input (string)

szyb opened this issue · comments

Consider code below:

//act
string result = GetResult();
//assert
result.ShouldContain("test string");

When result is null then the test will end up with exception: NullReferenceException.

StringHelpers.Clip(String stringToClip, Int32 maximumStringLength, String ellipsis) line 135
ShouldBeStringTestExtensions.ShouldContain(String actual, String expected, Case caseSensitivity, String customMessage) line 18
UnitTest1.Test1() line 13

In my opinion it should result in failing assertion, like:

Shouldly.ShouldAssertException : result
    should contain (case insensitive comparison)
"test string"
    but was actually
null