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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:30:47+00:00 2026-06-10T01:30:47+00:00

For unit testing purposes, is it possible to do this: Have test data in

  • 0

For unit testing purposes, is it possible to do this:

  • Have test data in some format (XML?) checked into source control
  • When unit tests are run, instantiate some kind of in memory database from this test data
  • Have EF run against this in memory database for the duration of the unit test run

?

We don’t want our unit tests to rely on a specific external database being present, and in a specific state.

We also don’t want to maintain two different “worlds” in our code and tests, the real world where EF runs against a real db and a fake work where our tests run against some kind of EF mock.

  • 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-06-10T01:30:48+00:00Added an answer on June 10, 2026 at 1:30 am

    Unit tests should not be dependent on any database. Any dependency on database (even in memory database) means you are doing integration tests and integration tests should be done against the real database you are going to use.

    I’m not aware of any XML database for EF but even if it exists you are back in front of your requirement: We also don’t want to maintain two different “worlds” in our code and test. Every database has its own EF provider created by different company. Even providers for MS SQL Server and MS SQL Server Compact Edition are different enough to make switching between them quite challenging.

    What you should do:

    • Hide all EF usage behind some abstraction (that includes everything including Linq-to-entities queries) and mock this abstraction instead of EF for unit tests
    • Use integration tests against the real database implementation you want to use in production for testing the abstraction itself
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For learning purposes, I dived into the field of unit testing. I've read through
For the purposes of unit testing, I would like to validate that two xml
I'm new in unit testing so may be I do something wrong. I have
I'm looking into unit testing and TDD for a Cocoa desktop application and I'd
Im trying to unit test a class in some Java code that I've inherited.
I use Eclipse + Maven and - for unit testing purposes - the web
I'm jumping into unit-testing the Visual-Studio 2008 way, and I'm wondering what's the best
For unit testing purposes I'm trying to write a mock object of a class
I have been trying to get the hang of TDD and unit testing (in
I am undergoing a unit test in 64-bit mongodb in 64-bit linux machine.I have

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.