使用SqlBulkCopy operaitons时Mocking是否可行? [英] Is Mocking possible when using SqlBulkCopy operaitons?

查看:87
本文介绍了使用SqlBulkCopy operaitons时Mocking是否可行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将大量数据插入SQL服务器时使用sqlbulkcopy操作。当我尝试进行单元测试时,我没有找到模拟SQLBulkCopy的方法。是否有相同的框架可用?或者如果有任何其他方式来实现
单元测试,请告诉我。

I am using sqlbulkcopy operations while inserting the large amount of data into SQL server. When I try to do the unit testing, i do not found the way to mock the SQLBulkCopy.. Is any framework available for the same? Or if any other ways to implement the Unit test, Please let me know. 

推荐答案

也许嘲笑不是这里最好的主意另一种方法是拥有一个测试数据库,如果需要将种子与开发数据库中的一些数据混合起来。在每个单元之前,测试方法将数据从dev复制到测试数据库,执行合并
并执行断言。

Perhaps mocking is not the best idea here, a alternate would be to have a test database, seed if need be to mix things up with some data from the development database. Prior to each unit test method runs copy data from dev to test database, perform the merge and do your assertions.

我有一个
MSDN代码示例
执行上述有关设置但不执行的操作合并但模式是合理的。

I have a MSDN code sample that does the above in regards to setting things up but does not do the merge yet the pattern is sound.

所有设置都是在测试类继承的基类中完成的。

All setup is done in a base class that the test class inherits.

最后,这个论坛真的是对于C#问题,如果您喜欢我自己或其他主持人可以将您的问题转移到单元测试论坛。

Lastly, this forum is really for C# questions, if you like myself or another moderator can move your question to the unit test forum.


这篇关于使用SqlBulkCopy operaitons时Mocking是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆