feat: Aggiunta gestione nome database sorgente nei profili DataCoupler
✨ Nuove funzionalità: - Aggiunto campo SourceDatabaseName nella tabella DataCouplerProfiles - Implementato recupero automatico del nome database dalle credenziali - Migliorata applicazione profili con supporto database specifico - Aggiornata logica di connessione database con selezione database 🔧 Modifiche tecniche: - Aggiunta migration per colonna SourceDatabaseName - Estesi modelli DataCouplerProfile e DataCouplerProfileDto - Aggiornato DataCouplerProfileService per gestire nuovo campo - Modificato ProfileSaver per recupero automatico database name - Implementato metodo ConnectToDatabaseWithSpecificDatabase 🐛 Correzioni: - Migliorata gestione connessioni database multi-database - Corretta formattazione codice e spaziature - Rimosse linee vuote eccessive nel codice sorgente 🧪
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using CredentialManager.Data;
|
||||
using CredentialManager.Models;
|
||||
using CredentialManager.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
Console.WriteLine("🧪 Testing SourceDatabaseName retrieval from credentials...");
|
||||
|
||||
// Configurazione del database temporaneo
|
||||
var options = new DbContextOptionsBuilder<CredentialDbContext>()
|
||||
.UseSqlite("Data Source=test_credential_db.db")
|
||||
.Options;
|
||||
|
||||
using var context = new CredentialDbContext(options);
|
||||
await context.Database.EnsureCreatedAsync();
|
||||
|
||||
var credentialService = new CredentialService(context);
|
||||
|
||||
// Test 1: Crea una credenziale database con nome database
|
||||
var testCredential = new DatabaseCredential
|
||||
{
|
||||
Name = "TestDatabaseCredential",
|
||||
DatabaseType = "SqlServer",
|
||||
Host = "localhost",
|
||||
Port = 1433,
|
||||
DatabaseName = "MyProductionDB",
|
||||
Username = "testuser",
|
||||
Password = "testpassword"
|
||||
};
|
||||
|
||||
Console.WriteLine($"📝 Creando credenziale con DatabaseName: {testCredential.DatabaseName}");
|
||||
var credentialId = await credentialService.SaveDatabaseCredentialAsync(testCredential);
|
||||
Console.WriteLine($"✅ Credenziale salvata con ID: {credentialId}");
|
||||
|
||||
// Test 2: Recupera la credenziale
|
||||
var retrievedCredential = await credentialService.GetDatabaseCredentialAsync(credentialId);
|
||||
Console.WriteLine($"✅ Credenziale recuperata: {retrievedCredential?.Name}");
|
||||
Console.WriteLine($" DatabaseName: {retrievedCredential?.DatabaseName}");
|
||||
|
||||
// Test 3: Simula il recupero del database name come farebbe ProfileSaver
|
||||
if (retrievedCredential != null && !string.IsNullOrEmpty(retrievedCredential.DatabaseName))
|
||||
{
|
||||
Console.WriteLine($"✅ SUCCESSO: DatabaseName recuperato dalle credenziali: {retrievedCredential.DatabaseName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("❌ ERRORE: DatabaseName non recuperato dalle credenziali");
|
||||
}
|
||||
|
||||
// Pulizia
|
||||
await context.Database.EnsureDeletedAsync();
|
||||
Console.WriteLine("🧹 Database temporaneo eliminato");
|
||||
|
||||
Console.WriteLine("\n🎯 Test completato con successo!");
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CredentialManager\CredentialManager.csproj" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user