- ABP Framework version: v3.0.4
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no / yes
- Exception message and stack trace: Unable to cast object of type 'Microsoft.Data.Sqlite.SqliteConnection' to type 'Npgsql.NpgsqlConnection
- Steps to reproduce the issue: As details below
Hi,
We have created custom repositories for our entities as per https://docs.abp.io/en/abp/latest/Repositories#custom-repositories. In one of our repository we one method which executes postgreSQL function as below :
public async Task<bool> UpdateInvoiceStatusInBulk(InvoiceStatusUpdateBulkDto updateInvoiceList, CancellationToken cancellationToken = default)
{
var result = false;
var data = JsonConvert.SerializeObject(updateInvoiceList);
await EnsureConnectionOpenAsync(cancellationToken);
using (var command = CreateCommand("SELECT \"UpdateInvoiceStatus\"(@data)", CommandType.StoredProcedure, new NpgsqlParameter("@data", data)))
{
result = (bool)command.ExecuteScalarAsync(cancellationToken).Result;
}
return result;
}
Normally this method works fine.
But while unit testing for the method which call UpdateInvoiceStatusInBulk
method internally gives error i.e. Unable to cast object of type 'Microsoft.Data.Sqlite.SqliteConnection' to type 'Npgsql.NpgsqlConnection
This is just because while unit testing we use sqlite db which is provided by framework.
I am not able to do testing of the method which internally calls the above method. How do I resolve this issue ?
2 Answer(s)
-
0
hi
You can consider skipping this test, or prepare a test database for this method.
-
0
This question has been automatically marked as stale because it has not had recent activity.