尝试使用 SQLite 进行工作正常的单元测试,但测试一些存储库是有问题的,因为它们使用事务。
对于使用 ReadCommitted 的事务,一切都很好,但是其中一些使用 ReadUncommitted 看看 System.Data.SQLite 不支持:
if ((this._defaultIsolation != IsolationLevel.Serializable) && (this._defaultIsolation != IsolationLevel.ReadCommitted))
{
throw new NotSupportedException("Invalid Default IsolationLevel specified");
}
我想知道,是否可以拦截 Session.BeginTransaction(...) 以便我可以更改事务级别,仅用于单元测试。
更新: 我的解决方案是下载 System.Data.SQLite 的源代码并修改异常以设置默认隔离级别。我在这里写博客:
http://www.philliphaydon.com/2011/01/system-data-sqlite-isolationlevel-exception/