क्या संग्रहAssert.AreEquivalent() के समान कुछ है जो नेस्टेड संग्रह के साथ काम करता है?NUnit Nested संग्रह तुलना
निम्नलिखित कोड ...
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" } } }
});
इस अपवाद फेंकता है ...
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]] >
निम्नलिखित ज़ोर से गुजरता है:
CollectionAssert.AreEquivalent (
new Dictionary < int, string > { { 10, "foo" }, { 11, "bar" }, { 12, "spam" } },
new Dictionary < int, string > { { 10, "foo" }, { 11, "bar" }, { 12, "spam" } });
अगर मैं उम्मीद संग्रह में परिवर्तन कर , संदेश में संदेश दोनों संग्रहों की पूरी सामग्री के साथ एक अपवाद फेंकता है:
Expected: equivalent to < [10, foo], [11, bar], [12, spam] >
But was: < [10, foo], [11, bar], [12, eggs] >
मैं NUnit 2.4.7.0 का उपयोग कर रहा हूं।
इसी तरह के प्रश्न: http://stackoverflow.com/questions/4185164/recursive-assert-on-collection –