Update on developing a “mock” entity framework provider.

by ChrisB October 03, 2007 02:10
Just an update on the mock entity framework provider - the idea behind it is so that you can develop unit tests against a disconnected dataset, which you can setup in memory as part of the tests, so that the data is in a known state  - rather than hitting a live database.  To that end I've been experimenting a bit with the sample entity framework provider.It seems that ObjectQuery<T> cannot be created without specifying a context and a query string.  Shame, otherwise I could simply mock the call to the NorthwindModel.Customers { get; } call, and return my own ObjectQuery<Customers> in place of the one the real provider would have returned.It seems that it's created in the entity framework code itself, where ther provider retrieves a datareader and converts it into an ObjectQuery of the class requested.This means that my "dataset framework provider"  will have to receive the eSql query command and return a data reader from the dataset that matches the eSql query.  This data reader will be picked up by the framework code, which will convert it to an ObjectQuery<T> instance.I found this quite useful "template data reader" on the msdn pages, where there is example code on how to create a data reader.  I plan to look into that a bit more.I will also need to work out how the "dataset framework provider" will actually be given the dataset.Once I have a working sample project, I'll probably chuck it up on codeplex (if David Sceppa's happy for me to, as it will use a large part of the sample entity framework code - I'll have to check).[tags]entity framework, mock, provider[/tags]

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Archive

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen | Modified by Mooglegiant

About the author

Chris Buckett develops .net applications in C# and VB.Net, and is being persuaded to start developing for Java.

Tag cloud

Page List