Use supported SQL client provider

This commit is contained in:
2026-08-26 18:16:29 +00:00
parent bac1eacac6
commit 8bbf905668
51 changed files with 605 additions and 320 deletions

View File

@@ -1,8 +1,11 @@
using System.Data.Common;
using System.Reflection;
using SmartB2B.Enova.Contracts;
using SmartB2B.Enova.Service.Configuration;
using SmartB2B.Enova.Service.Orders;
using SmartB2B.Enova.Service.Rpc;
using SmartB2B.Enova.Service.Runtime;
using SmartB2B.Enova.Service.Sql;
using WampSharp.Core.Serialization;
using WampSharp.V2.Core;
using WampSharp.V2.Core.Contracts;
@@ -27,7 +30,8 @@ var tests = new (string Name, Func<Task> Run)[]
("Brak katalogu Enovy jest wykrywany", MissingEnovaDirectory),
("Sekrety są odczytywane z pliku konfiguracji", SecretsComeFromConfigurationFile),
("Brak danych operatora wyłącza place_order", MissingCredentialsDisablePlaceOrder),
("Częściowe dane operatora wyłączają place_order", PartialCredentialsDisablePlaceOrder)
("Częściowe dane operatora wyłączają place_order", PartialCredentialsDisablePlaceOrder),
("Provider SQL działa na bieżącej platformie", SqlProviderIsSupported)
};
var failures = 0;
@@ -48,6 +52,28 @@ foreach (var test in tests)
Console.WriteLine($"Wynik: {tests.Length - failures}/{tests.Length} testów zaliczonych.");
return failures == 0 ? 0 : 1;
static Task SqlProviderIsSupported()
{
var handler = new SqlRawHandler(
"Server=localhost;Database=master;Integrated Security=true;TrustServerCertificate=true",
30);
var createConnection = typeof(SqlRawHandler).GetMethod(
"CreateConnection",
BindingFlags.Instance | BindingFlags.NonPublic)
?? throw new InvalidOperationException("Nie znaleziono metody tworzącej połączenie SQL.");
using var connection = (DbConnection)(createConnection.Invoke(handler, null)
?? throw new InvalidOperationException("Provider nie utworzył połączenia SQL."));
if (connection.GetType().FullName != "Microsoft.Data.SqlClient.SqlConnection")
{
throw new InvalidOperationException(
$"Załadowano nieoczekiwany provider SQL: {connection.GetType().AssemblyQualifiedName}.");
}
return Task.CompletedTask;
}
static Task ValidFractionalDiscount()
{
AssertNoErrors(CreateValidRequest(12.5m));