LinqToSQL:Alternative to mocking the Db

by alski 30. April 2009 16:32

One of the really nice things about LinqToSQL is how simple it makes it to produce a new database. It fact it's so easy you can produce a real DB with less effort than a Mock'd one.

I'm sure this has to be bad in some way, but I've no idea what that is yet. I'll need to try it out on a decent environment with a Build Server (like at home).

public const string UnitTestConnection = "Data Source=.;Initial Catalog=UnitTest;Integrated Security=True";
...
MyDataContext context = new MyDataContext(UnitTestConnection);
if (context.DatabaseExists())
{
    context.DeleteDatabase();
}
context.CreateDatabase();
context.SubmitChanges();

Be the first to rate this post

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

Tags: , , ,

Code | LINQ

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

RecentComments

Comment RSS