Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vbreuss committed Oct 30, 2023
1 parent 8938479 commit 78df3d1
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 99 deletions.
Expand Up @@ -16,8 +16,8 @@ public void Succeed_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act / Assert
actual.Should().Be(expect, o => o.Using(comparer));
Expand All @@ -28,8 +28,8 @@ public void Fail_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act
Action act = () => actual.Should().Be(expect, o => o.Using(comparer));
Expand Down Expand Up @@ -431,8 +431,8 @@ public void Succeed_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act / Assert
actual.Should().NotBe(expect, o => o.Using(comparer));
Expand All @@ -443,8 +443,8 @@ public void Fail_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act
Action act = () => actual.Should().NotBe(expect, o => o.Using(comparer));
Expand Down
Expand Up @@ -18,8 +18,8 @@ public void Succeed_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act / Assert
actual.Should().BeEquivalentTo(expect, o => o.Using(comparer));
Expand All @@ -30,8 +30,8 @@ public void Fail_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act
Action act = () => actual.Should().BeEquivalentTo(expect, o => o.Using(comparer));
Expand Down Expand Up @@ -185,8 +185,8 @@ public void Succeed_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act / Assert
actual.Should().NotBeEquivalentTo(expect, o => o.Using(comparer));
Expand All @@ -197,8 +197,8 @@ public void Fail_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act
Action act = () => actual.Should().NotBeEquivalentTo(expect, o => o.Using(comparer));
Expand Down Expand Up @@ -351,30 +351,4 @@ public void When_the_actual_string_equivalent_to_the_expected_but_with_trailing_
act.Should().NotThrow();
}
}

private sealed class MatchingEqualityComparer : IEqualityComparer<string>
{
public bool Equals(string x, string y)
{
return true;
}

public int GetHashCode(string obj)
{
return obj.GetHashCode();
}
}

private sealed class NotMatchingEqualityComparer : IEqualityComparer<string>
{
public bool Equals(string x, string y)
{
return false;
}

public int GetHashCode(string obj)
{
return obj.GetHashCode();
}
}
}
Expand Up @@ -16,8 +16,8 @@ public void Succeed_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act / Assert
actual.Should().ContainEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -28,8 +28,8 @@ public void Fail_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act
Action act = () => actual.Should().ContainEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -42,7 +42,7 @@ public void Fail_for_same_strings_using_custom_not_matching_comparer()
public void Succeed_for_case_different_strings_when_IgnoringCase()
{
// Arrange
string actual = "test";
string actual = "this is a string containing test.";
string expect = "TEST";

// Act / Assert
Expand All @@ -53,7 +53,7 @@ public void Succeed_for_case_different_strings_when_IgnoringCase()
public void Succeed_for_leading_whitespace_different_strings_when_IgnoringLeadingWhitespace()
{
// Arrange
string actual = " test";
string actual = " this is a string containing test.";
string expect = "test";

// Act / Assert
Expand All @@ -64,7 +64,7 @@ public void Succeed_for_leading_whitespace_different_strings_when_IgnoringLeadin
public void Succeed_for_trailing_whitespace_different_strings_when_IgnoringTrailingWhitespace()
{
// Arrange
string actual = "test ";
string actual = "this is a string containing test. ";
string expect = "test";

// Act / Assert
Expand All @@ -75,7 +75,7 @@ public void Succeed_for_trailing_whitespace_different_strings_when_IgnoringTrail
public void Succeed_for_newline_different_strings_when_IgnoringNewlines()
{
// Arrange
string actual = "\rA\nB\r\nC\n";
string actual = "this is a string containing \rA\nB\r\nC.\n";
string expect = "ABC";

// Act / Assert
Expand Down Expand Up @@ -500,8 +500,8 @@ public void Succeed_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act / Assert
actual.Should().NotContainEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -512,8 +512,8 @@ public void Fail_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act
Action act = () => actual.Should().NotContainEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -526,7 +526,7 @@ public void Fail_for_different_strings_using_custom_matching_comparer()
public void Fail_for_case_different_strings_when_IgnoringCase()
{
// Arrange
string actual = "test";
string actual = "this is a string containing test.";
string expect = "TEST";

// Act
Expand All @@ -540,7 +540,7 @@ public void Fail_for_case_different_strings_when_IgnoringCase()
public void Fail_for_leading_whitespace_different_strings_when_IgnoringLeadingWhitespace()
{
// Arrange
string actual = " test";
string actual = " this is a string containing test.";
string expect = "test";

// Act
Expand All @@ -554,7 +554,7 @@ public void Fail_for_leading_whitespace_different_strings_when_IgnoringLeadingWh
public void Fail_for_trailing_whitespace_different_strings_when_IgnoringTrailingWhitespace()
{
// Arrange
string actual = "test ";
string actual = "this is a string containing test. ";
string expect = "test";

// Act
Expand All @@ -568,7 +568,7 @@ public void Fail_for_trailing_whitespace_different_strings_when_IgnoringTrailing
public void Fail_for_newline_different_strings_when_IgnoringNewlines()
{
// Arrange
string actual = "\rA\nB\r\nC\n";
string actual = "this is a string containing \rA\nB\r\nC.\n";
string expect = "ABC";

// Act
Expand Down
Expand Up @@ -17,8 +17,8 @@ public void Succeed_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act / Assert
actual.Should().EndWithEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -29,8 +29,8 @@ public void Fail_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act
Action act = () => actual.Should().EndWithEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -43,7 +43,7 @@ public void Fail_for_same_strings_using_custom_not_matching_comparer()
public void Succeed_for_case_different_strings_when_IgnoringCase()
{
// Arrange
string actual = "test";
string actual = "prefix for test";
string expect = "TEST";

// Act / Assert
Expand All @@ -54,7 +54,7 @@ public void Succeed_for_case_different_strings_when_IgnoringCase()
public void Succeed_for_leading_whitespace_different_strings_when_IgnoringLeadingWhitespace()
{
// Arrange
string actual = " test";
string actual = " prefix for test";
string expect = "test";

// Act / Assert
Expand All @@ -65,7 +65,7 @@ public void Succeed_for_leading_whitespace_different_strings_when_IgnoringLeadin
public void Succeed_for_trailing_whitespace_different_strings_when_IgnoringTrailingWhitespace()
{
// Arrange
string actual = "test ";
string actual = "prefix for test ";
string expect = "test";

// Act / Assert
Expand All @@ -76,7 +76,7 @@ public void Succeed_for_trailing_whitespace_different_strings_when_IgnoringTrail
public void Succeed_for_newline_different_strings_when_IgnoringNewlines()
{
// Arrange
string actual = "\rA\nB\r\nC\n";
string actual = "prefix for \rA\nB\r\nC\n";
string expect = "ABC";

// Act / Assert
Expand Down Expand Up @@ -176,8 +176,8 @@ public void Succeed_for_same_strings_using_custom_not_matching_comparer()
{
// Arrange
var comparer = new NotMatchingEqualityComparer();
string actual = "test";
string expect = "test";
string actual = "ABC";
string expect = "ABC";

// Act / Assert
actual.Should().NotEndWithEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -188,8 +188,8 @@ public void Fail_for_different_strings_using_custom_matching_comparer()
{
// Arrange
var comparer = new MatchingEqualityComparer();
string actual = "test A";
string expect = "test B";
string actual = "ABC";
string expect = "XYZ";

// Act
Action act = () => actual.Should().NotEndWithEquivalentOf(expect, o => o.Using(comparer));
Expand All @@ -202,7 +202,7 @@ public void Fail_for_different_strings_using_custom_matching_comparer()
public void Fail_for_case_different_strings_when_IgnoringCase()
{
// Arrange
string actual = "test";
string actual = "prefix for test";
string expect = "TEST";

// Act
Expand All @@ -216,7 +216,7 @@ public void Fail_for_case_different_strings_when_IgnoringCase()
public void Fail_for_leading_whitespace_different_strings_when_IgnoringLeadingWhitespace()
{
// Arrange
string actual = " test";
string actual = " prefix for test";
string expect = "test";

// Act
Expand All @@ -230,7 +230,7 @@ public void Fail_for_leading_whitespace_different_strings_when_IgnoringLeadingWh
public void Fail_for_trailing_whitespace_different_strings_when_IgnoringTrailingWhitespace()
{
// Arrange
string actual = "test ";
string actual = "prefix for test ";
string expect = "test";

// Act
Expand All @@ -244,7 +244,7 @@ public void Fail_for_trailing_whitespace_different_strings_when_IgnoringTrailing
public void Fail_for_newline_different_strings_when_IgnoringNewlines()
{
// Arrange
string actual = "\rA\nB\r\nC\n";
string actual = "prefix for \rA\nB\r\nC\n";
string expect = "ABC";

// Act
Expand Down

0 comments on commit 78df3d1

Please sign in to comment.