内存DBMS用于单元测试 [英] In-memory DBMS's for unit testing

查看:66
本文介绍了内存DBMS用于单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找令人满意的选项来对.NET DAL类进行单元测试;由于它们是DAL类,因此它们直接使用ADO.NET访问数据库.目前,我使用MSSQL数据库的实例进行测试,但是想知道有哪些更快的选项-因为单元测试需要尽快运行,因此内存中的解决方案将是理想的选择.

I am looking for satisfactory options for unit testing my .NET DAL classes; since they're DAL classes, they access the database directly using ADO.NET. Presently I use an instance of a MSSQL database for the testing, but was wondering what faster options there are---since unit tests need to run as quickly as possible, an in-memory solution would be ideal.

我还应该提到,由于我只会使用Microsoft平台,所以我将自己绑定到TSQL.

I should also mention that I have tied myself to TSQL since I'm only ever going to be using a Microsoft platform.

推荐答案

鉴于您声明:

我还应该提到我已经绑因为只有我,所以我自己也要使用TSQL将要使用微软平台.

I should also mention that I have tied myself to TSQL since I'm only ever going to be using a Microsoft platform.

然后使用SqlServer Compact Edition可以很好地满足您的需求.它不会完全在内存中运行,但可以以只读模式运行(在该模式下,不会对主数据库文件进行任何编辑,因此可以一次被多个测试使用)

Then Using SqlServer compact Edition may work well for your needs. It will not operate entirely in memory but can operate in a readonly mode (where no edits occur to the main database file so it can be used by multiple tests at once)

有一些陷阱,不支持存储过程,需要转换一些数据类型,并且某些数据类型有严格的限制(特别是varchar,它只能达到4000个字符)也不正确支持Linq to Sql.

There are a few gotchas, no stored procedures are supported, a few data types need to be translated and certain data types have tight limits (notably varchar which can only go to 4000 characters) Linq to Sql also is not properly supported.

尽管如此,我还是使用SqlServer Compact Edition作为适当的Sql Server数据库的几乎完全替代品,效果很好.

Nonetheless I have used a SqlServer Compact Edition as an almost entirely drop replacement for the proper Sql Server database with good results.

这篇关于内存DBMS用于单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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