Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

New Post: Should().Equal() vs Assert.AreEqual on empty collections

$
0
0

I'm struggling with something. I'm looking to verify that two empty lists refer to the same object:

    var liste1 = new List<string>();
    var liste2 = new List<string>();
    (liste1 == liste2).Should().BeFalse();
    liste1.Should().Equal(liste2);   // This one passes, but I thought it was using Object.Equals ?
    Assert.AreEqual(liste1, liste2); // This one fails, which is what I want in this case 

Is there another Fluent method I could use to compare the two references?

            var liste1 = new List<string>();
            var liste2 = new List<string>();
            (liste1 == liste2).Should().BeFalse();
            liste1.Should().Equal(liste2);   // This one passes, but I thought it was using Object.Equals ?
            Assert.AreEqual(liste1, liste2); // This one fails, which is what I want in this case

Viewing all articles
Browse latest Browse all 1402

Trending Articles