如何单元测试数据库依赖行为C# [英] How to unit test database depended behavior C#

查看:305
本文介绍了如何单元测试数据库依赖行为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个C#应用程序与DB通信。我想测试一些依赖于DB的函数。所以我想确保DB在每次测试运行之前具有初始状态。我使用NUnit来测试我的应用程序。有什么方法可以恢复DB的初始状态?

谢谢您的帮助!


I have a C# application which communicates with DB. I want to test some functions which depend on DB. So I want to be sure that DB has an initial state before each test run. I use NUnit to test my application. What means are available to restore an initial state of DB?
Thank you for your help!

推荐答案

您可以在内存中使用SQLite数据库创建测试数据库环境。

You may use in memory SQLite database for creating test db environment.

SQLite Nunit& Fluent Nhibernate - 测试您的数据访问层

这篇关于如何单元测试数据库依赖行为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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