views:

44

answers:

1

Hi

I'm using Linq to sql to access an SQL Server.
I try to write all my database queries in a partial class so they can be accessed directly from the DataContext. Now I would like to test the Data Context but I can't figure out the best way och doing that.

Bascially I need to test 3 things:
1. The queries return the correct data (no more no less)
2. The Stored Procedure calls return the correct data
3. Many to many relationships are configured correctly in the dbml (deleteonnull)

I've seem simular questions here but none of them (I have found) addresses all 3 problems.
Using an interface only gives me access to the tables not the methods in the partial class.
I have played around with using interface and placing all my query methods as extension methods for the interface but that doesn't work with the SP call.

So what is the best way of testing Linq To SQL DataContexts (and queries).
Any suggestions?

/Jimmy

A: 

I'm not sure if I understood you I think that you need unit testing, possibly combined with automatic sample data generation (database edition of Visual Studio can do that for you).

Konamiman
Thanks, I would have prefered not to use a database but I relize thats probably the only way of doing that.Thanks.
Jimmy Engtröm