Skip to content

Commit

Permalink
#2755: Tests for another embedded collection regression (v2)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Sep 22, 2023
1 parent e499f14 commit 9ab4ece
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/xunit.assert/Asserts
Submodule Asserts updated 47 files
+12 −1 .editorconfig
+112 −101 CollectionAsserts.cs
+9 −8 EqualityAsserts.cs
+6 −4 Guards.cs
+7 −2 Sdk/ArgumentFormatter.cs
+1 −1 Sdk/AssertComparer.cs
+4 −4 Sdk/AssertEqualityComparer.cs
+1 −1 Sdk/AssertEqualityComparerAdapter.cs
+5 −2 Sdk/AssertHelper.cs
+22 −14 Sdk/CollectionTracker.cs
+0 −3 Sdk/CollectionTrackerExtensions.cs
+4 −1 Sdk/Exceptions/AllException.cs
+3 −1 Sdk/Exceptions/CollectionException.cs
+12 −12 Sdk/Exceptions/ContainsException.cs
+2 −2 Sdk/Exceptions/DistinctException.cs
+18 −4 Sdk/Exceptions/DoesNotContainException.cs
+2 −2 Sdk/Exceptions/DoesNotMatchException.cs
+2 −2 Sdk/Exceptions/EmptyException.cs
+2 −0 Sdk/Exceptions/EqualException.cs
+12 −12 Sdk/Exceptions/EquivalentException.cs
+4 −5 Sdk/Exceptions/FalseException.cs
+2 −2 Sdk/Exceptions/InRangeException.cs
+1 −1 Sdk/Exceptions/IsAssignableFromException.cs
+2 −2 Sdk/Exceptions/IsNotAssignableFromException.cs
+2 −0 Sdk/Exceptions/IsNotTypeException.cs
+1 −1 Sdk/Exceptions/IsTypeException.cs
+1 −1 Sdk/Exceptions/MatchesException.cs
+1 −2 Sdk/Exceptions/MultipleException.cs
+4 −4 Sdk/Exceptions/NotEqualException.cs
+2 −2 Sdk/Exceptions/NotInRangeException.cs
+1 −1 Sdk/Exceptions/NotNullException.cs
+2 −2 Sdk/Exceptions/NotStrictEqualException.cs
+2 −2 Sdk/Exceptions/NullException.cs
+2 −2 Sdk/Exceptions/ProperSubsetException.cs
+2 −2 Sdk/Exceptions/ProperSupersetException.cs
+1 −1 Sdk/Exceptions/PropertyChangedException.cs
+1 −1 Sdk/Exceptions/RaisesAnyException.cs
+3 −3 Sdk/Exceptions/RaisesException.cs
+2 −2 Sdk/Exceptions/SameException.cs
+6 −1 Sdk/Exceptions/SingleException.cs
+1 −1 Sdk/Exceptions/SkipException.cs
+2 −2 Sdk/Exceptions/StrictEqualException.cs
+2 −2 Sdk/Exceptions/SubsetException.cs
+2 −2 Sdk/Exceptions/SupersetException.cs
+3 −3 Sdk/Exceptions/ThrowsAnyException.cs
+4 −4 Sdk/Exceptions/ThrowsException.cs
+2 −0 Sdk/IAssertionException.cs
148 changes: 148 additions & 0 deletions test/test.xunit.assert/Asserts/CollectionAssertsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,80 @@ public static void WithCollectionValues_NotEqual()
ex.Message
);
}

[Fact]
public void ComplexEmbeddedValues_Equal()
{
var expected = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value" }
}
}
}
};
var actual = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value" }
}
}
}
};

Assert.Equal(expected, actual);
}

[Fact]
public void ComplexEmbeddedValues_NotEqual()
{
var expected = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value1" }
}
}
}
};
var actual = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value2" }
}
}
}
};

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

Assert.IsType<EqualException>(ex);
Assert.Equal(
"Assert.Equal() Failure: Dictionaries differ" + Environment.NewLine +
"Expected: [[\"key\"] = [[\"key\"] = [[[\"key\"] = [\"value1\"]]]]]" + Environment.NewLine +
"Actual: [[\"key\"] = [[\"key\"] = [[[\"key\"] = [\"value2\"]]]]]",
ex.Message
);
}
}

public class Sets
Expand Down Expand Up @@ -1607,6 +1681,80 @@ public static void WithCollectionValues_NotEqual()

Assert.NotEqual(expected, actual);
}

[Fact]
public void ComplexEmbeddedValues_Equal()
{
var expected = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value" }
}
}
}
};
var actual = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value" }
}
}
}
};

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

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

[Fact]
public void ComplexEmbeddedValues_NotEqual()
{
var expected = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value1" }
}
}
}
};
var actual = new Dictionary<string, object>()
{
["key"] = new Dictionary<string, object>()
{
["key"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
["key"] = new List<object> { "value2" }
}
}
}
};

Assert.NotEqual(expected, actual);
}
}

public class Sets
Expand Down

0 comments on commit 9ab4ece

Please sign in to comment.