开发者

How to test a stored procedure with LINQTOSQL

开发者 https://www.devze.com 2023-02-10 08:19 出处:网络
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 p

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消