Finally, after the question has been settled, I would propose the following thing.
This would be the class structure I would use to organize the table entries.
public class MyTable
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public MyTable(int Id, string Name, string Surname)
{
this.Id = Id;
this.Name = Name;
this.Surname = Surname;
}
}
Then, this would be my test method
[Fact]
public void RemovesAllInstancesOfDuplicateEntries()
{
var mylist = new List<MyTable>();
mylist.Add(new MyTable(1 , "John" , "Miller"));
mylist.Add(new MyTable(2 , "Jessica", "Scot"));
mylist.Add(new MyTable(3 , "Robert", "Johnes"));
mylist.Add(new MyTable(4 , "John", "Miller"));
var actual = new MySUT().RemoveAllInstancesOfDuplicates(mylist);
Assert.Equal(2, actual.Count);
Assert.Equal(2, actual[0].Id);
Assert.Equal(3, actual[1].Id);
}
And, my implementation of the test would be the following
public List<MyTable> RemoveAllInstancesOfDuplicates(List<MyTable> myTable)
{
List<MyTable> withoutAllInstancesOfDuplicates = new List<MyTable>();
foreach(MyTable entry in myTable)
{
if (myTable.Count(row =>
string.Equals(row.Name, entry.Name) &&
string.Equals(row.Surname, entry.Surname)) == 1)
{
withoutAllInstancesOfDuplicates.Add(entry);
}
}
return withoutAllInstancesOfDuplicates;
}