¿Hay algo similar a CollectionAssert.AreEquivalent() que funcione con colecciones anidadas?NUnit Comparación de colecciones anidadas
El siguiente código ...
CollectionAssert.AreEquivalent (
new Dictionary<int, Dictionary<int, string>>
{
{ 1, new Dictionary < int, string > { { 10, "foo" }, { 11, "bar" }, { 12, "spam" } } },
{ 2, new Dictionary < int, string > { { 20, "eggs" }, { 21, "eels" } } },
{ 3, new Dictionary < int, string > { { 30, "hovercraft" } } }
},
new Dictionary<int, Dictionary<int, string>>
{
{ 1, new Dictionary < int, string > { { 10, "foo" }, { 11, "bar" }, { 12, "spam" } } },
{ 2, new Dictionary < int, string > { { 20, "eggs" }, { 21, "eels" } } },
{ 3, new Dictionary < int, string > { { 30, "hovercraft" } } }
});
lanza esta excepción ...
Expected: equivalent to
< [1, System.Collections.Generic.Dictionary`2[System.Int32,System.String]],
[2, System.Collections.Generic.Dictionary`2[System.Int32,System.String]],
[3, System.Collections.Generic.Dictionary`2[System.Int32,System.String]] >
But was:
< [1, System.Collections.Generic.Dictionary`2[System.Int32,System.String]],
[2, System.Collections.Generic.Dictionary`2[System.Int32,System.String]],
[3, System.Collections.Generic.Dictionary`2[System.Int32,System.String]] >
La siguiente aserción pasa:
CollectionAssert.AreEquivalent (
new Dictionary < int, string > { { 10, "foo" }, { 11, "bar" }, { 12, "spam" } },
new Dictionary < int, string > { { 10, "foo" }, { 11, "bar" }, { 12, "spam" } });
Si hago cambios en la colección de espera , la declaración arroja una excepción con todo el contenido de ambas colecciones en el mensaje:
Expected: equivalent to < [10, foo], [11, bar], [12, spam] >
But was: < [10, foo], [11, bar], [12, eggs] >
Estoy usando NUnit 2.4.7.0.
pregunta similar: http://stackoverflow.com/questions/4185164/recursive-assert-on-collection –