Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Firstly, as others have pointed out, you have to correctly implement <code>Equals</code> method.</p> <pre class="lang-cs prettyprint-override"><code>public override bool Equals(Object obj) { if (obj == null) return false; CustomerLead other = obj as CustomerLead; if ((Object)other == null) return false; // here you need to compare two objects // below is just example implementation return this.FirstName == other.FirstName &amp;&amp; this.LastName == other.LastName &amp;&amp; this.EmailAddress == other.EmailAddress; } </code></pre> <p><br> Secondly, in your test method, you must not use result values from method you're testing to prepare expected collection. If <code>unSortedLeads</code> method has simple error and swaps <code>FirstName</code> with <code>LastName</code> you will never find such error with this test. Instead you should use literal values.</p> <pre class="lang-cs prettyprint-override"><code>[TestMethod()] public void unSortedLeadsTest() { // read objects from xml string xml = "C:/Users/Admin/Downloads/potentialcustomers.xml"; CustomerLeads target = new CustomerLeads(); List&lt;CustomerLead&gt; actual = target.unSortedLeads(xml); // prepare expected collection List&lt;CustomerLead&gt; expected = new List&lt;CustomerLead&gt;() { new CustomerLead() { FirstName = "FirstName1", LastName = "LastName1", EmailAddress = "Email@Address1" }, new CustomerLead() { FirstName = "FirstName2", LastName = "LastName2", EmailAddress = "Email@Address2" }, new CustomerLead() { FirstName = "FirstName3", LastName = "LastName3", EmailAddress = "Email@Address3" } }; // test equality CollectionAssert.AreEqual(expected, actual); } </code></pre> <p><br> You can read more about implementing <code>Equals</code> method <a href="http://msdn.microsoft.com/en-us/library/vstudio/336aedhh%28v=vs.100%29.aspx">here</a> and about unit testing <a href="http://msdn.microsoft.com/en-us/library/jj159340.aspx">here</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload