I have a database repository with a bunch of access functions. Now I want to create a fake repository that provides similar functionality for unittests. Unlike a real repository, this one uses simple lists, not classes created using linqtosql.
Most fake repository functions look exactly the same as real ones, with just the extra ToQueryable () at the end. However, I now have one that seems to require a more complex translation.
public class FakeUserRepository : IUserRepository {
public IQueryable<SelectListItem> GetRecords(int userid) {
return (from a in fake_table select
new SelectListItem {
Value = a.ID.ToString(),
Text = a.Name
});
}
}
This currently gives the error "Cannot implicitly convert type" to System.Collections.Generic.IEnumerable.) I am not surprised by the error message, but I have no idea how to fix the cast.