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.
Keith is a Senior Software Engineer with Falafel Software. He has been developing software since 1999 specializing in web-based solutions primarily using the Microsoft stack. He has been a Microsoft MVP in ASP.NET since 2012.
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.