LinqToSQL:Alternative to mocking the Db

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();

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s