NUnit, CollectionAssert.AreEquivalent(...,...), C# Question

Posted by K-Bell on Stack Overflow See other posts from Stack Overflow or by K-Bell
Published on 2010-03-19T20:17:42Z Indexed on 2010/03/19 20:21 UTC
Read the original article Hit count: 219

Filed under:
|

I new to NUnit and looking for an explination as to why this test fails?

I get the following exception when running the test.

NUnit.Framework.AssertionException: Expected: equivalent to < <....ExampleClass>, <....ExampleClass> > But was: < <....ExampleClass>, <....ExampleClass> >

using NUnit.Framework;
using System.Collections.ObjectModel;

public class ExampleClass
{
    public ExampleClass()
    {
        Price = 0m;
    }

    public string Description { get; set; }
    public string SKU { get; set; }
    public decimal Price { get; set; }
    public int Qty { get; set; }
}

[TestFixture]
public class ExampleClassTests
{
    [Test]
    public void ExampleTest()
    {

        var collection1 = new Collection<ExampleClass>
               {
                     new ExampleClass
                         {Qty = 1, SKU = "971114FT031M"},
                     new ExampleClass
                         {Qty = 1, SKU = "971114FT249LV"}
                 };

        var collection2 = new Collection<ExampleClass>
               {
                     new ExampleClass
                         {Qty = 1, SKU = "971114FT031M"},
                     new ExampleClass
                         {Qty = 1, SKU = "971114FT249LV"}
                 };

        CollectionAssert.AreEquivalent(collection1, collection2);

    }
}

© Stack Overflow or respective owner

Related posts about nunit

Related posts about c#