Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1040097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:10:55+00:00 2026-05-16T15:10:55+00:00

Yet another simple question about unit testing model objects that uses data access layer.

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:10:55+00:00Added an answer on May 16, 2026 at 3:10 pm

    Yes, this is precisely the fee you pay for it not being an integration test. It’s a good idea to have integration tests as well as unit tests, of course.

    It’s hard to avoid this sort of problem with ORMs, in my experience – how are you going to emulate the whole of SQL Server accurately without running SQL Server? That doesn’t mean ORMs are useless or anything like that – just that there are limitations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for yet another question about EF4 context lifespan, but I've been wondering about
I have yet another .htaccess question, simple for you, not so much for me.
Yet another data structure doubt. I will get straight to it. This is what
Yet another PHP question. I've got two arrays: one string-based and the other numeric.
I've just added yet another 3rd-party component to my .net project that contains a
ok, yet another jquery selector nightmare for me ! I've read about 20 questions
First, I am NOT trying to spur yet another debate about LINQ vs. stored
Yet another IE is doing something different from other browsers question but this is
this is yet another OpenCV installation question, however I wasn't able to find an
Yes, this is probably yet another greatest-n-per-group question... But I've tried at least a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.