c# - IndexOf find no element in a List<> while Mock -
i have list of object below public class person { public string name {get; set;} public int age {get; set;} } public class someclass { public int dosomething () { int result; list<person> personlist = new list<person>(); personlist.add(new person { //with 1 object, keep simple name = "someone", age = 18}); person eighteenyearsold = _checkage.findeighteenyearsold (personlist); int index = personlist.indexof (eighteenyearsold); //do return result; } } [testmethod] public void dosomething_test() { //given: //when: call someclass object person eightnneyears = new person { name = "someone", age = 18}; _mockcheckage.setup (x => x.findeighteenyearsold(it.isany<list<person>>())).returns(eightnneyears); _someclass = new someclass (_mockcheckage.object); int result = _someclass.dosomething(); //then: } as have mocked findeighteenyearsold method returns perso...