我似乎无法找出为什么我会收到此错误,actual
并且expected
在索引 0 处返回相同的值并且具有完全相同的属性。这个问题的可能原因是什么?我环顾四周,但到目前为止还找不到任何可行的解决方案。
[TestMethod()]
public void unSortedLeadsTest()
{
List<CustomerLead> expected = new List<CustomerLead>();
List<CustomerLead> actual = new List<CustomerLead>();
CustomerLeads target = new CustomerLeads(); // TODO: Initialize to an appropriate value
string xml = "C:/Users/Admin/Downloads/potentialcustomers.xml"; // TODO: Initialize to an appropriate value
actual = target.unSortedLeads(xml);
CustomerLead lead = new CustomerLead()
{
FirstName = actual[0].FirstName,
LastName=actual[0].LastName,
EmailAddress=actual[0].EmailAddress
};
CustomerLead lead1 = new CustomerLead()
{
FirstName = actual[1].FirstName,
LastName = actual[1].LastName,
EmailAddress = actual[1].EmailAddress
};
CustomerLead lead2 = new CustomerLead()
{
FirstName = actual[2].FirstName,
LastName = actual[2].LastName,
EmailAddress = actual[2].EmailAddress
};
target.addressList.Add(lead);
target.addressList.Add(lead1);
target.addressList.Add(lead2);
foreach (CustomerLead i in target.addressList) {
expected.Add(lead);
}
// TODO: Initialize to an appropriate value
CollectionAssert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
编辑:我试图覆盖 Equals 但正在苦苦挣扎:有什么想法可以实现这一目标吗?
public override bool Equals(Object obj)
{
if (obj == null)
return false;
CustomerLead leadsequal = obj as CustomerLead;
if ((Object)leadsequal == null)
return false;
else
return Equals( leadsequal);
}