Click here to Skip to main content
15,885,767 members
Articles / DevOps / Unit Testing

Two Strategies for Testing Entity Framework - Effort and SQL CE

Rate me:
Please Sign up or sign in to vote.
4.97/5 (14 votes)
19 Sep 2012CPOL6 min read 117.6K   2.5K   27  
Two approaches for unit testing Entity Framework
In this article, you will learn about two approaches for unit testing Entity Framework: Mocking in memory by using "Effort", and against a real database using SQLCE
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="TempDatabaseFolder" value="C:\code\TestingEf\TestTemp"/>
  </appSettings>
  <connectionStrings>
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <!-- Need this in here for the tests to work correctly.  
        The Effort library registers the provider itself (as the invarient "EffortProvider" - without "Test"), 
        but the SQL CE implementation will override it. 
        This configuration will create a different registration for it. -->
      <add name="Effort Provider Test" description="Effort Provider for unit testing" invariant="EffortProviderTest" type="Effort.Provider.EffortProviderFactory,Effort"/>
    </DbProviderFactories>
  </system.data>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions