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.
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.