# Sunday, April 26, 2009

I figured I was to the point where I was comfortable enough with the concept of mocking that I would start implementing it in one of the projects I am working on at my current client.  The data access layer of the application obtains data from two sources; a CIS system that is only reachable via web services and a data warehouse on a SQL Server that we are accessing directly using stored procedures and LINQ to SQL.  I started with mocking the web service piece and that went off without a hitch. 

The Linq To SQL piece did not go as smoothly.  I had a few issues creating the Interface for the DataContext and then ran into trying to mock System.Data.Linq.Table which is Sealed.  Instead of copying and pasting the code in the post and explaining it I think that I will let the code speak for itself.  If you are like me you find it much easier to understand complex code in the solution structure offered by Visual Studio.  So grab the code from here and dive in.

Monday, April 27, 2009 8:24:21 AM (Central Daylight Time, UTC-05:00)
Nice post Keith. Mocking complex infrastructure classes is a major pain and something not typically done. Hiding that stuff behind a repository or facade of some sort will give you persistence ignorance, offering mocking Zen by giving you a simple interface to mock.

Linq to sql would probably only require integration tests - tests to ensure the correct tables are hit and expected data is returned. As for unit testing, abstract the ugly stuff behind gateways/facades/etc. and you will simplify your life.

corey
Monday, April 27, 2009 8:32:57 AM (Central Daylight Time, UTC-05:00)
Corey,
Thanks for the comment. I would be interested in seeing an example of the points you made.
Monday, April 27, 2009 10:45:21 PM (Central Daylight Time, UTC-05:00)
Samples are everywhere. Here's a quick list of results I dug up.

The first few samples are pretty good examples.

http://www.google.com/search?q=linq+to+sql+repository&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
corey
Thursday, January 13, 2011 12:08:42 AM (Central Standard Time, UTC-06:00)
Giving someone all your love cheap ugg boots sale is never an assurance that they will love discount ugg boots you back! Do not wait for love in return,just wait for cheap ugg boots it to grow in their ugg boots heart but if does not,be content it grows in ugg boots sale yours.It takes only a minute to get a crush on someone,but it takes a http://www.goodfurboots.com/ lifetime to forget someone.
Sunday, January 23, 2011 11:23:30 PM (Central Standard Time, UTC-06:00)
Be The Talk Of The Party By <b>belstaff townmaster jacket</b> Putting On A Fancy <b>belstaff town master motorcycle jacket</b> Jacket
content:
<p>Fancy <b>belstaff tourmaster trophy jacket</b> jackets are a natural choice for <b>belstaff tourmaster summer jacket</b> many women during the winter <b>belstaff thruxton jacket</b> and rainy seasons. These <b>belstaff the departed jacket</b> jackets are dynamic and can be <b>belstaff textile jacket</b> worn with a variety of nice <b>belstaff stoke jacket</b> tops along with <b>belstaff snetterton jacket</b> pants.<p>Fancy jackets deliver a <b>belstaff siskin jacket</b> complete and attractive look and <b>belstaff silverstone jacket</b> usually end up creating a feel <b>belstaff sammy miller replica jacket</b> good notion in the mind <b>belstaff sammy miller jacket</b> body and spirit of whoever <b>belstaff roadmaster motorcycle jacket</b> wears them. This is why they <b>belstaff rider blouson jacket black</b> have become so popular and <b>belstaff rider blouson jacket</b> people buy them on a consistent <b>belstaff redford jacket</b> basis.<p>People who look up <b>belstaff rebel jacket</b> to Elvis Presley and Michael <b>belstaff rallymaster jacket</b> Jackson in terms of fashion <b>belstaff raf jacket</b> will surely relate to these <b>belstaff racing blouson leather jacket</b> jackets. The main reason <b>belstaff racing blouson jacket</b> for this is because these were <b>belstaff racemaster jacket</b> their signature <b>belstaff r6 jacket</b> designs.<p>When it comes to comfort, <b>belstaff preston jacket</b> these jackets are a top item <b>belstaff panther timeless jacket</b> on the list of comfortable <b>belstaff panther jacket medium</b> clothes. They might be a <b>belstaff outlaw jacket</b> little expensive but offer a <b>belstaff original 50 jacket</b> complete look if one is headed <b>belstaff omega jacket</b> to a party where they might <b>belstaff olivers mojave vintage leather blouson jacket</b> need to depict the gangster <b>belstaff nylon jacket</b> look.<p>As already mentioned; <b>belstaff new tourist trophy jacket</b> these jackets flow well <b>belstaff new delta force jacket</b> with a number of other clothes <b>belstaff motorcycle jacket for sale</b> and are very appropriate for
agag
Wednesday, June 29, 2016 7:31:21 AM (Central Daylight Time, UTC-05:00)
Hi there, ӏ discovered your website viaa Google ɑt thᥱ
sme time as lߋoking for ɑ comparable matter,
уߋur web sitte gоt hегe up, it looks great.
I havе bookmarked іt in my google bookmarks.

Hi there, simply turned іnto aware οf your blog via Google, ɑnd located that
іt is truly informative. І'm gonna watch oսt foг brussels.
І'll аppreciate in caqse үou proceed this inn future.

Many other folks ᴡill bee benefited fгom your writing.
Cheers!
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview