I have been attempting to learn how we can mock out calls to entity framework in our project. I ran into this problem where we are using EntityFunctions.TruncateTime. The error says: this function can only be invoked from linq to entities. If this should be supported help on what i'm doing wrong, if its not then i guess we are out of luck for those scenarios.
Thanks
John
from audit
in
_context.Audits
where audit.DTS < EntityFunctions.TruncateTime(mydate)
select audit
var fakeEntities = Mock.Create<SomeDBEntities>();
var audits = GetAudits();
Mock.Arrange(() => fakeEntities.Audits).ReturnsCollection(audits);
var target =
new
ReportRepository(fakeEntities);
var result = target.test(DateTime.Now);
Assert.AreEqual(2, result.Count());
John