Search code examples
tddnunitmstest

Why empty collection assertion does not work in MSTest?


I have an assertion like the following

Assert.AreEqual(1.Primes(), new List());

Where Primes returns IList and the code for primes is

public static class PrimesKata { public static IList Primes(this int n) { return new List(); } }

as you can guess I am trying out the prime number kata, when using MSTest for unit testing this test fails but the same code works just fine in NUnit. Is there something extra I need to do in MSTest for this test to pass?


Solution

  • NUnit's Assert supports equality of collections.

    MSUnit doesn't. You can use CollectionAssert in MSTest instead.

    In .NET (unlike Java, for instance) two lists are not equal just because they have the same contents.