Reputation: 193
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?
Upvotes: 1
Views: 475
Reputation: 32946
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
Upvotes: 2