title: CollectionAssert use with generics?
body: <p>It appears that <code>CollectionAssert</code> cannot be used with generics. This is super frustrating; the code I want to test does use generics. What am I to do? Write boilerplate to convert between the two? Manually check collection equivalence?</p>
  
  <p>This fails:</p>
  
  <pre><code>ICollection&lt;IDictionary&lt;string, string&gt;&gt; expected = // ...
  
  IEnumerable&lt;IDictionary&lt;string, string&gt;&gt; actual = // ...
  
  // error 1 and 2 here
  CollectionAssert.AreEqual(expected.GetEnumerator().ToList(), actual.ToList());
  
  // error 3 here
  Assert.IsTrue(expected.GetEnumerator().SequenceEquals(actual));
  </code></pre>
  
  <p>Compiler errors:</p>
  
  <p>Error 1:</p>
  
  <blockquote>
    <p>'System.Collections.Generic.IEnumerator>' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Collections.Generic.IEnumerator>' could be found</p>
  </blockquote>
  
  <p>Error 2</p>
  
  <blockquote>
    <p>'System.Collections.Generic.IEnumerator>' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Collections.Generic.IEnumerator>' could be found</p>
  </blockquote>
  
  <p>Error 3</p>
  
  <blockquote>
    <p>'System.Collections.Generic.IEnumerator>' does not contain a definition for 'SequenceEquals' and no extension method 'SequenceEquals' accepting a first argument of type 'System.Collections.Generic.IEnumerator>' could be found</p>
  </blockquote>
  
  <p>What am I doing wrong? Am I not using extensions correctly?</p>
  
  <p><strong>Update:</strong> Ok, this looks a bit better, but still doesn't work:</p>
  
  <pre><code>IEnumerable&lt;IDictionary&lt;string, string&gt;&gt; expected = // ...
  
  IEnumerable&lt;IDictionary&lt;string, string&gt;&gt; actual = // ...
  
  CollectionAssert.AreEquivalent(expected.ToList(), actual.ToList()); // fails
  CollectionAssert.IsSubsetOf(expected.ToList(), actual.ToList()); // fails
  </code></pre>
  
  <p>I don't want to be comparing lists; I only care about set membership equality. The order of the members is unimportant. How can I get around this?</p>