Coder 2
Coder 2

Reputation: 4881

How to test a stored procedure with LINQTOSQL

Can someone please tell me how you're supposed to test a stored procedure given that the LINQ datacontext.CreateDatabase() I use to create my test database doesn't create the stored procedure.

It seems difficult to test it in your test procedure if it doesn't exist.

Upvotes: 2

Views: 364

Answers (2)

Adam Rackis
Adam Rackis

Reputation: 83358

I think you're supposed to create your stored procedure first, then add it to your L2S context, then just call it in a unit test. Of course you'll want to set up a special test database first. Also, obviously, be sure to clean up your database after each test to minimize side effects between tests.

Upvotes: 2

J.W.
J.W.

Reputation: 18181

The point of unit testing is not to touch your database, so if you have business logic based on the database, you need separate this dependency by using something like Repository pattern to return a value or values which you normally will get from the stored procedure.

Upvotes: 0

Related Questions