I am trying to assert two items in my collection as I have two entities in my collection. One way that i am trying is just doing a foreach loop and asserting them individually like below. But in this approach, my second item in this collection would have different items.I mean to say that It is passing for first item in collection but not for other as my second item has different values to be compared with..
How can I compare my second item in this way. Or if you have any other idea, please let me know.
foreach (var item in result.Entities)
{
Assert.AreEqual("Contractor1", item.ContractorName, "Result not found");
Assert.AreEqual(1234, item.PKey, "Result not found");
Assert.AreEqual("Alex", item.Name, "Result not found");
}
or what i can do is write if condition within foreach that if it is first item then compare with this otherwise use other values??
So, here is what i did::
foreach (var item in result.Entities)
{
if (result.Entities.First() == item)
{
// Assert First Item
}
else{
//Assert second list
}
}
but i need a better solution.