mardi 4 août 2015

Using npgsql in a unit test

I'm trying to use npgsql in a very short xunit backed unit test. I am using the ncrunch test runner (from within VS 2015).

From read that I need to register the npgsql data provider in order to use it. In both the dll being tested and test dll I have added an App.config containing:

<system.data> <DbProviderFactories> <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" /> </DbProviderFactories> </system.data>

When I attempt to open an npgsql connection (via npoco) I am getting this error:

System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed. at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at NPoco.Database..ctor(String connectionString, DatabaseType dbType, Nullable`1 isolationLevel, Boolean enableAutoSelect) in d:\Dev\NPoco\src\NPoco\Database.cs:line 100 at NPoco.Database..ctor(String connectionString, DatabaseType dbType) in d:\Dev\NPoco\src\NPoco\Database.cs:line 85 at CalcEngine.CalculationSetQuery.Foo() in C:\Users\sam.critchley\source\calcengine\src\CalcEngine\ICalculationSetQuery.cs:line 19 at CalcEngine.Tests.X.Test() in C:\Users\sam.critchley\source\calcengine\src\CalcEngine.Tests\ParameterSorterTests.cs:line 16

The stack trace would seem to indicate this error doesn't have anything to do with nPoco itself.

Does anyone know how to get this running/what might be wrong?

Aucun commentaire:

Enregistrer un commentaire