简体   繁体   中英

How do I configure SQLite under .NET/C# to run in NUnit tests?

I am writing NUnit tests and want to use the in-memory database SQLite (.NET) with my DAL. I thought that since it is in-memory it shouldn't be such a big deal to run unit tests with it. I have no trouble setting up an executable to run with SQLite. I add the SQLite dll-references and include the correct DbProviderFactories settings in the App.config file and it works.

However, when I run nunit tests I have trouble getting the data store provider:

System.ArgumentException : The specified store provider cannot be found in the configuration, or is not valid.
  ----> System.ArgumentException : Unable to find the requested .Net Framework Data Provider.  It may not be installed.

I tried to do the same process with the test project as i would with a executable project but it doesn't work.

How do I configure SQLite to run in NUnit tests?

I don't know if it helps you.

I use Fluent nHibernate, its light and awesome.

http://www.dotnetguy.co.uk/post/2009/10/20/sqlite-nunit-fluent-nhibernate-test-your-data-access-layer/

I have had the same problem. For me it worked when i switched the SQLite from x86 to x64 (or vice versa, can't remember).

If you're using NuGet: There is (confusingly) 3 different packages for SQLite .

I also use FluentNH combined with a Repository pattern for data access. It's super simple to set up for both tests and application :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM