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 523877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:30:28+00:00 2026-05-13T08:30:28+00:00

I’ve implemented unit testing along the lines of this article with a fake object

  • 0

I’ve implemented unit testing along the lines of this article with a fake object context and IObjectSet with POCO in EF4.

http://blogs.msdn.com/adonet/archive/2009/12/17/test-driven-development-walkthrough-with-the-entity-framework-4-0.aspx

But I’m unsure how to implement a couple of methods on my fake object context for testing. I have CreateQuery and ExecuteFunction methods on my object context interface so that I can execute ESQL and Stored Procedures but I cant (easily) implement them in my fake object context.

An alternative would be to use a test double of my repository instead of a double of my object context as suggested here:

http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/c4921443-e8a3-4414-92dd-eba1480a07ad/

But this would mean my real repository isnt being tested and would seem to just bypass the issue.

Can anyone offer any recommendations?

  • 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-13T08:30:28+00:00Added an answer on May 13, 2026 at 8:30 am

    As far as I can tell from the question, you are trying to test too much at the same time. Keep the Single Responsibility Principle in mind.

    When we unit test, we use abstract Repositories to abstract the data access code away from the rest of the application. From this perspective, we are only testing the consumers of the Repositories, not any concrete Repository at all. Such consumers should care only about the Repositories, and not at all about any ‘object context’ – that would be a Leaky Abstraction.

    Imagine that you are unexpectedly being asked to wire your Repository consumers up to a completely different data layer (e.g. a REST-based service). In such cases, even an abstract object context makes no sense. You may not ever expect this to happen, but even so, the thought experiment alone is a pretty good indicator of a Leaky Abstraction.

    The object context is an implementation detail of your concrete Repository implementation that uses EF. Other implementations may not need an object context at all.

    That said, you may still want to test the EF implementation itself. That may make a lot of sense, but that’s a different unit test suite with an entirely different purpose. Instead of testing the consumers of your abstract Repositories, you are now testing a concrete implementation of a Repository. In this case, there’s no need to go through the interfaces – you can talk directly to the concrete types here.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this

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.