Select to view content in your preferred language

Unit testing with a database file for Arcgis Pro SDK

2158
2
Jump to solution
09-26-2019 08:02 AM
by Anonymous User
Not applicable

Hi, I'm looking for a way to test the result of a query to a geodatabase and/or sqlite database file when running unit tests with Nunit in C# (Visual Studio 2017 Enterprise) for an add-in. Right now, I always get an error about this missing DLL: MappingCoreLib.dll when I create a queudTask to open the database even if I added this DLL in the project. I had the same issue with DADFLib.dll but adding the file to the project solved the issue for this specific file.

When I run the add-in, everything is working fine and the add-in project is compiling without issue which mean the SDK is correctly installed.

The problem happen when I run this section of my unit test:

if (File.Exists(gdbFile.AbsolutePath))
{
Database database;

await QueuedTask.Run(() =>
{
using (database = new Database(new SQLiteConnectionPath(gdbFile)))
{
database.OpenTable(database.GetQueryDescription("ROADS"));
}
});
}


Error message: System.DllNotFoundException: 'Unable to load DLL 'MappingCoreLib.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

This error happen when trying to open gdb or a sqlite file.

Anybody had this issue before and know a way to solve it? Thank you

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

I finally solved my problem:

1) My test project was not compiling correctly and I had to manually set it to x64

2) All the manual dll import is NOT necessary with Nunit 3, I simply had to use the method Host.Initialize() at the beginning of my test and all the dependency issues are solved. Make sure to run the test in a STA thread by using this before the test: [Test, Apartment(ApartmentState.STA)]

3) Using the Host.Initialize() method allow me to open the database without issue too.

View solution in original post

2 Replies
by Anonymous User
Not applicable

I finally solved my problem:

1) My test project was not compiling correctly and I had to manually set it to x64

2) All the manual dll import is NOT necessary with Nunit 3, I simply had to use the method Host.Initialize() at the beginning of my test and all the dependency issues are solved. Make sure to run the test in a STA thread by using this before the test: [Test, Apartment(ApartmentState.STA)]

3) Using the Host.Initialize() method allow me to open the database without issue too.

Cristian_Galindo
Frequent Contributor

I am migrating to .NET 6, for the migration to ArcGIS Pro 3.0 SDK, and have some Manual UI test..... same Error.

 

Man you are a savior.

I owe you a beer

0 Kudos