Yet another "simple" question about unit testing model objects that uses data access layer.
When I mock my Table<Customer> to IQuerable<ICustomer>, where new List<FakeCustomer>().AsQuerable() is used in role of in memory data store, the following code passes unit test perfectly:
var filteredCustomers = from c in dal.Customers
where c.Code.ToUpperInvariant() == "ABC"
select c;
When running app I of course get NotSupportedException (because of ToUpperInvariant()). Maybe it is rather lame example, because problem there can be fixed by replacing ToUpperInvariant() to ToUpper(), but you got the point.
Question: is such inconsistency a "fee" for writing real unit but not integration tests? Or maybe I am doing something wrong, e.g. there should be another way to mock DataContext in a way that fully emulates Linq To SQL DataContext?
Currently I am queuing a test database instead of in-memory mock to catch such an errors.
Thanks for your suggestions.