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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer <? $query="SELECT * FROM gender; $result = mysql_query ($query); echo… May 17, 2026 at 8:43 am
  • Editorial Team
    Editorial Team added an answer class ConcatenatedStream : Stream { Queue<Stream> streams; public ConcatenatedStream(IEnumerable<Stream> streams)… May 17, 2026 at 8:43 am
  • Editorial Team
    Editorial Team added an answer Yes it's absolutely fine to use PNG's with Alpha Transparency.… May 17, 2026 at 8:43 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

ok simple question about including large mostly static html and asp.net code I am
First, I am NOT trying to spur yet another debate about LINQ vs. stored
Yet again, my teacher was unable to answer my question. I knew who may
If I have a subclass that has yet to implement a function provided by
Quick question, hopefully I am just missing something simple. Ok I have one class
Update: I can't delete this question, because the answer has been upvoted, yet it
I'm new to C++, and I have a question that should be easy, but
This is quite a simple concept, but as of yet I have been unable
Hey all, I am trying to accomplish something very simple yet getting an error
Better yet, how can I make My Computer always open in Explorer as well?

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.