I'm trying to mock the following stuff:
_reportsRepo.Expect(x => x.Table.FirstOrDefault(s => s.MessageId == 1)).Return(new Report { Id = 1 });
but i get ArgumentNullException. Any ideas?
I think you can just do something along these lines:
_reportsRepo.Expect(x => x.Table).Return(new []{Report { Id = 1 }});
depending on exactly what type Table is.
you can't mock FirstOrDefault
instead you should mock the enumeration which it is returning so that it returns a collection which fulfils your requirements
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.