forked from shouldly/shouldly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed null string comparison (shouldly#538)
* Failing tests that difference should not be shown for missing string * Stop showing misleading difference for missing string
- Loading branch information
1 parent
e7a25cc
commit c4aa6f5
Showing
5 changed files
with
109 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Shouldly.Tests/Strings/DetailedDifference/CaseInsensitive/NullScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Xunit; | ||
|
||
namespace Shouldly.Tests.Strings.DetailedDifference.CaseInsensitive | ||
{ | ||
public static class NullScenario | ||
{ | ||
[Fact] | ||
public static void ShouldNotShowDifferenceWhenActualIsMissing() | ||
{ | ||
var str = (string)null; | ||
Verify.ShouldFail(() => | ||
str.ShouldBe("null", StringCompareShould.IgnoreCase), | ||
|
||
errorWithSource: | ||
@"str | ||
should be with options: Ignoring case | ||
""null"" | ||
but was | ||
null", | ||
|
||
errorWithoutSource: | ||
@"null | ||
should be with options: Ignoring case | ||
""null"" | ||
but was not"); | ||
} | ||
|
||
[Fact] | ||
public static void ShouldNotShowDifferenceWhenExpectedIsMissing() | ||
{ | ||
var str = "null"; | ||
Verify.ShouldFail(() => | ||
str.ShouldBe(null, StringCompareShould.IgnoreCase), | ||
|
||
errorWithSource: | ||
@"str | ||
should be with options: Ignoring case | ||
null | ||
but was | ||
""null""", | ||
|
||
errorWithoutSource: | ||
@"""null"" | ||
should be with options: Ignoring case | ||
null | ||
but was not"); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Shouldly.Tests/Strings/DetailedDifference/CaseSensitive/NullScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Xunit; | ||
|
||
namespace Shouldly.Tests.Strings.DetailedDifference.CaseSensitive | ||
{ | ||
public static class NullScenario | ||
{ | ||
[Fact] | ||
public static void ShouldNotShowDifferenceWhenActualIsMissing() | ||
{ | ||
var str = (string)null; | ||
Verify.ShouldFail(() => | ||
str.ShouldBe("null"), | ||
|
||
errorWithSource: | ||
@"str | ||
should be | ||
""null"" | ||
but was | ||
null", | ||
|
||
errorWithoutSource: | ||
@"null | ||
should be | ||
""null"" | ||
but was not"); | ||
} | ||
|
||
[Fact] | ||
public static void ShouldNotShowDifferenceWhenExpectedIsMissing() | ||
{ | ||
var str = "null"; | ||
Verify.ShouldFail(() => | ||
str.ShouldBe(null), | ||
|
||
errorWithSource: | ||
@"str | ||
should be | ||
null | ||
but was | ||
""null""", | ||
|
||
errorWithoutSource: | ||
@"""null"" | ||
should be | ||
null | ||
but was not"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters