Skip to content

Commit

Permalink
Unit tests for #2803 (v3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Oct 25, 2023
1 parent 35b0587 commit cf53a9f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
58 changes: 58 additions & 0 deletions src/xunit.v3.assert.tests/Asserts/EqualityAssertsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,35 @@ void assertFailure(Action action)
}
}

public class KeyValuePair
{
[Fact]
public void CollectionValues_Equal()
{
var expected = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value1b" });
var actual = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value1b" });

Assert.Equal(expected, actual);
}

[Fact]
public void CollectionValues_NotEqual()
{
var expected = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value1b" });
var actual = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value2a" });

var ex = Record.Exception(() => Assert.Equal(expected, actual));

Assert.IsType<EqualException>(ex);
Assert.Equal(
"Assert.Equal() Failure: Values differ" + Environment.NewLine +
"Expected: [\"Key1\"] = [\"Value1a\", \"Value1b\"]" + Environment.NewLine +
"Actual: [\"Key1\"] = [\"Value1a\", \"Value2a\"]",
ex.Message
);
}
}

public class DoubleEnumerationPrevention
{
[Fact]
Expand Down Expand Up @@ -3274,6 +3303,35 @@ public void Truncation()
}
}

public class KeyValuePair
{
[Fact]
public void CollectionValues_Equal()
{
var expected = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value1b" });
var actual = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value1b" });

var ex = Record.Exception(() => Assert.NotEqual(expected, actual));

Assert.IsType<NotEqualException>(ex);
Assert.Equal(
"Assert.NotEqual() Failure: Values are equal" + Environment.NewLine +
"Expected: Not [\"Key1\"] = [\"Value1a\", \"Value1b\"]" + Environment.NewLine +
"Actual: [\"Key1\"] = [\"Value1a\", \"Value1b\"]",
ex.Message
);
}

[Fact]
public void CollectionValues_NotEqual()
{
var expected = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value1b" });
var actual = new KeyValuePair<string, List<string>>("Key1", new() { "Value1a", "Value2a" });

Assert.NotEqual(expected, actual);
}
}

public class DoubleEnumerationPrevention
{
[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/xunit.v3.assert/Asserts

0 comments on commit cf53a9f

Please sign in to comment.