C# Unit Testing - Generating Mock DataContexts / LINQ -> SQL classes
.net, c#, database, testing
Solution
The problem with the DataContext is that it isn't designed for mocking.
A free tool for mocking the unmockable is Moles from Pex (Pex moles?). Its roughly equivalent to TypeMock.
Problem
I am loving the new world that is C#, I've come to a point with my toy programs where I want to start writing some unit tests. My code currently uses a database via a DatabaseDataContext object (*.dbml file), what's the best way to create a mock for this object? Given how easy it is to generate the database LINQ -> SQL code and how common a request this must be I'm hoping that VS2010 has built in functionality to help with testing. If I'm way off and this must be done manually could you please enlighten me as to your preferred approach? Many Thanks, Gavin