<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Unit Testing Your Entity Framework Domain Classes</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx</link><description>Technorati Tags: Entity Framework , TDD One interesting question customers that are TDD practitioners usually ask is how to do unit testing with the Entity Framework using mock objects. That is, testing only the domain logic part of the model, without</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Unit Testing Your Entity Framework Domain Classes</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#9952820</link><pubDate>Mon, 25 Jan 2010 07:45:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9952820</guid><dc:creator>Diego B Vega</dc:creator><description>&lt;p&gt;Jason,&lt;/p&gt;
&lt;p&gt;It is interesting that you say that. What makes you think that you cannot use a mocking framework with EF? I wrote this post a long time ago, when we were still planning the second version of Entity Framework. There have been plenty of new articles about the subject since then, from members of the team and from other parties. Also, a new version of Entity Framework is now in beta (you can download it together with Visual Studio 2010 and .NET 4.0 beta 2 here: &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx&lt;/a&gt;) that supports better separation of concerns and persistence ignorance. A new interface called IObjectSet was added to simplify the creation of test doubles (i.e. mocks, fakes, etc.) in some scenarios. &lt;/p&gt;
&lt;p&gt;Besides, even without much other help from EF than Persistence Ignorance support, defining an abstract repository can separate your data access code from the rest of your application and provides a good place to inject test doubles. &lt;/p&gt;
&lt;p&gt;I would certainly recommend learning more about Entity Framework, especially EF 4.0, and considering it when you decide what O/RM to use for your next project. &lt;/p&gt;
&lt;p&gt;Here is some recommended reading:&lt;/p&gt;
&lt;p&gt;How to use TypeMock to break dependencies and mock EF 3.5 SP1&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://mosesofegypt.net/post/Introducing-Entity-Framework-Unit-Testing-with-TypeMock-Isolator.aspx"&gt;http://mosesofegypt.net/post/Introducing-Entity-Framework-Unit-Testing-with-TypeMock-Isolator.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A Sneak Preview of the testability improvements in EF 4:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/adonet/archive/2009/05/18/sneak-preview-entity-framework-4-0-testability-improvements.aspx"&gt;http://blogs.msdn.com/adonet/archive/2009/05/18/sneak-preview-entity-framework-4-0-testability-improvements.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A walkthrough on how to use the new testability improvements in EF 4:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/adonet/pages/walkthrough-test-driven-development-with-the-entity-framework-4-0.aspx"&gt;http://blogs.msdn.com/adonet/pages/walkthrough-test-driven-development-with-the-entity-framework-4-0.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Diego&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9952820" width="1" height="1"&gt;</description></item><item><title>re: Unit Testing Your Entity Framework Domain Classes</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#9952525</link><pubDate>Sun, 24 Jan 2010 05:00:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9952525</guid><dc:creator>Jason</dc:creator><description>&lt;P&gt;Unit Testing using a mocking framework isn't possible when using the Entity Framework. I'm disappointed to learn that EF is not viable for production level applications. &lt;/P&gt;
&lt;P&gt;If you were building an application that would be at the core of your business, what .Net based ORM would you recommend using? Due to the size and complexity of the application, the team distribution, etc., it must be unit testable; e.g., mock-friendly. &lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Jason&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9952525" width="1" height="1"&gt;</description></item><item><title>re: Unit Testing Your Entity Framework Domain Classes</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#9340343</link><pubDate>Mon, 19 Jan 2009 19:56:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9340343</guid><dc:creator>Diego B Vega</dc:creator><description>&lt;p&gt;Hi Whut, &lt;/p&gt;
&lt;p&gt;Sorry it took some time for me to answer. I have given some more thought lately to the approach described in Andrew’s blog, and I believe it is worth pursuing. &lt;/p&gt;
&lt;p&gt;I have to mention, though, that in the first version of Entity Framework, there are enough limitations in LINQ to Entities that you may need to be more careful what kind of LINQ query you write.&lt;/p&gt;
&lt;p&gt;There are some limitations that are not shared by Entity SQL (i.e. the case with date arithmetic not being accessible from LINQ to Entities) and in those cases it might make sense to write a separate parameterized method that will compose the first part of the query in Entity SQL and then return the IQueryable&amp;lt;T&amp;gt; so that you can continue composing it in LINQ.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Diego&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9340343" width="1" height="1"&gt;</description></item><item><title>Model-View-ViewModel</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#9315162</link><pubDate>Tue, 13 Jan 2009 17:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9315162</guid><dc:creator>Robert Folkesson</dc:creator><description>&lt;p&gt;Jag talar ofta med kunder och partners som vill anv&amp;#228;nda vedertagna designm&amp;#246;nster f&amp;#246;r att separera ansvaret&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9315162" width="1" height="1"&gt;</description></item><item><title>re: Unit Testing Your Entity Framework Domain Classes</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#9285635</link><pubDate>Tue, 06 Jan 2009 18:06:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9285635</guid><dc:creator>Alex G</dc:creator><description>&lt;p&gt;I wish the people at MS in the EF team had considered Domain Driven Design and TDD *before* they set out to create the EF. It's not like there's anything left to invent... stick to the patterns... we just want a common implementation that respect SEPARATION OF CONCERNS and PERSISTENCE IGNORANCE... oh &amp;nbsp;and some helper tools!&lt;/p&gt;
&lt;p&gt;Anyway, back to datareader for me... slightly more tedious, but we'll get real persitance ignorance and a TDD-able domain layer, and 10 times the performance... our datacenter is big enough without having to waste racks, power and CPU cycles. &lt;/p&gt;
&lt;p&gt;Otherwise, great work... I am impressed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9285635" width="1" height="1"&gt;</description></item><item><title>re: Unit Testing Your Entity Framework Domain Classes</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#9245698</link><pubDate>Sun, 21 Dec 2008 21:58:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9245698</guid><dc:creator>Whut</dc:creator><description>&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://andrewpeters.net/2007/04/28/fixing-leaky-repository-abstractions-with-linq/"&gt;http://andrewpeters.net/2007/04/28/fixing-leaky-repository-abstractions-with-linq/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What about such approach? I'm novice in Unit Testing, but this sounds simple and powerfl solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9245698" width="1" height="1"&gt;</description></item><item><title>re: Unit Testing Your Entity Framework Domain Classes</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#8975232</link><pubDate>Fri, 03 Oct 2008 10:56:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8975232</guid><dc:creator>Peter Morris</dc:creator><description>&lt;p&gt;I've recently blogged about unit testing security in business objects. &amp;nbsp;Might be of interest:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://mrpmorris.blogspot.com/2008/09/unit-testing-security.html"&gt;http://mrpmorris.blogspot.com/2008/09/unit-testing-security.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8975232" width="1" height="1"&gt;</description></item><item><title>Diego Vega ponders Unit Testing with Entity Framework</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#8118271</link><pubDate>Sun, 09 Mar 2008 20:54:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8118271</guid><dc:creator>Hot Topics</dc:creator><description>&lt;p&gt;Diego Vega, a Program Manager on the EF team at Microsoft, considers the challenges of Unit Testing EF&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8118271" width="1" height="1"&gt;</description></item><item><title>Then, should I write a data access layer or not?</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#8007157</link><pubDate>Mon, 03 Mar 2008 21:12:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8007157</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;Danny and I appear to be giving inconsistent advice on this regard in our recent weekend posts: Danny&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8007157" width="1" height="1"&gt;</description></item><item><title>Then, should I write a data access layer or not?</title><link>http://blogs.msdn.com/b/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx#8006674</link><pubDate>Mon, 03 Mar 2008 20:45:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8006674</guid><dc:creator>Diego's Data Access Blog</dc:creator><description>&lt;p&gt;Danny and I appear to be giving inconsistent advice on this regard in our recent weekend posts: Danny:&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8006674" width="1" height="1"&gt;</description></item></channel></rss>