Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
using (var fake = new SystemUnderTest.AutoFakeContainer())
{
List<Employee> emplist = new List<Employee>();
emplist.Add(new Employee { Name = "Emp_1", BasicSalary = 1000, Id = Guid.NewGuid(), HRA = 100, DA = 10, TotalSalary = 1110 });
emplist.Add(new Employee { Name = "Emp_2", BasicSalary = 1000 * 2, Id = Guid.NewGuid(), HRA = 200, DA = 20, TotalSalary = 2220 });
emplist.Add(new Employee { Name = "Emp_3", BasicSalary = 1000 * 3, Id = Guid.NewGuid(), HRA = 300, DA = 30, TotalSalary = 3330 });
var empRep = new EmployeeRepository();
var support = fake.Resolve<ISupport>();
var CalSalary = fake.Resolve<ICalSalaryClass>();


A.CallTo(() => support.FindAllEmp()).Returns(emplist);
A.CallTo(() => CalSalary.CalculateSalary(100)).WithAnyArguments().Returns(emplist);
var result = empRep.CallSupportFindAll();


// CollectionAssert.AreEqual(emplist, result);
Assert.AreEqual(emplist, result);
var r1 = result[0];
Assert.AreEqual(r1.Name, emplist[0].Name);
Assert.AreEqual(r1.TotalSalary, emplist[0].TotalSalary);
Assert.AreEqual(r1.BasicSalary, emplist[0].BasicSalary);

}


I want to compare two list emplist and result list which is return from method callSupportfindAll(). here Assert.AreEqual(r1.Name, emplist[0].Name); worked but if we have thousands of record then need to write thousands of line. so please answer-- for one line code for compare two list... thanks in advance
Posted
Comments
phil.o 11-Apr-15 2:21am    
Repost. Please delete one of your questions, and avoid posting the same question more than once.

1 solution

There is a little thing in every language known as a loop.
C#
for(int i = 0 ; i<result.length;>{
   // you can figure out the rest!
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900