Ripulata cartella progetto
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
|
||||||
<clear />
|
|
||||||
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
|
|
||||||
</packageSources>
|
|
||||||
</configuration>
|
|
||||||
@@ -35,7 +35,7 @@ builder.Services.AddHttpClient();
|
|||||||
|
|
||||||
// Register Data Connection Factory
|
// Register Data Connection Factory
|
||||||
builder.Services.AddScoped<IDataConnectionFactory, DataConnectionFactory>();
|
builder.Services.AddScoped<IDataConnectionFactory, DataConnectionFactory>();
|
||||||
//builder.WebHost.UseUrls("http://*:7550");
|
builder.WebHost.UseUrls("http://*:7550");
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
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!");
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using CredentialManager;
|
|
||||||
using CredentialManager.Services;
|
|
||||||
using CredentialManager.Models;
|
|
||||||
|
|
||||||
Console.WriteLine("🧪 Testing DataCouplerProfile Service...");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Crea un service provider con CredentialManager
|
|
||||||
var serviceProvider = await CredentialManagerFactory.CreateServiceProviderAsync();
|
|
||||||
|
|
||||||
// Ottieni il servizio per i profili
|
|
||||||
var profileService = serviceProvider.GetRequiredService<IDataCouplerProfileService>();
|
|
||||||
|
|
||||||
Console.WriteLine("✅ Service created successfully!");
|
|
||||||
|
|
||||||
// Test: Ottieni tutti i profili (dovrebbe essere vuoto)
|
|
||||||
var profiles = await profileService.GetAllProfilesAsync();
|
|
||||||
Console.WriteLine($"📋 Found {profiles.Count()} existing profiles");
|
|
||||||
|
|
||||||
// Test: Crea un profilo di test
|
|
||||||
var testProfile = new DataCouplerProfile
|
|
||||||
{
|
|
||||||
Name = "Test Profile",
|
|
||||||
Description = "Profile creato durante il test",
|
|
||||||
SourceType = "database",
|
|
||||||
DestinationType = "rest",
|
|
||||||
SourceSchema = "dbo",
|
|
||||||
SourceTable = "customers",
|
|
||||||
DestinationEndpoint = "/api/customers",
|
|
||||||
CreatedBy = "System Test"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Salva il profilo
|
|
||||||
var savedProfile = await profileService.SaveProfileAsync(testProfile);
|
|
||||||
Console.WriteLine($"💾 Test profile saved with ID: {savedProfile.Id}");
|
|
||||||
|
|
||||||
// Ricarica i profili
|
|
||||||
profiles = await profileService.GetAllProfilesAsync();
|
|
||||||
Console.WriteLine($"📋 Now found {profiles.Count()} profiles");
|
|
||||||
|
|
||||||
// Elimina il profilo di test
|
|
||||||
var deleted = await profileService.DeleteProfileAsync(savedProfile.Id);
|
|
||||||
Console.WriteLine($"🗑️ Test profile deleted: {deleted}");
|
|
||||||
|
|
||||||
Console.WriteLine("✅ All tests passed! DataCouplerProfile service is working correctly.");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"❌ Error during testing: {ex.Message}");
|
|
||||||
Console.WriteLine($"Stack trace: {ex.StackTrace}");
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("Press any key to exit...");
|
|
||||||
Console.ReadKey();
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<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" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
using CredentialManager.Data;
|
|
||||||
using CredentialManager.Models;
|
|
||||||
using CredentialManager.Services;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
Console.WriteLine("🧪 Testing SourceDatabaseName database persistence...");
|
|
||||||
|
|
||||||
// Configurazione del database temporaneo
|
|
||||||
var options = new DbContextOptionsBuilder<CredentialDbContext>()
|
|
||||||
.UseSqlite("Data Source=test_sourcedatabase.db")
|
|
||||||
.Options;
|
|
||||||
|
|
||||||
using var context = new CredentialDbContext(options);
|
|
||||||
await context.Database.EnsureCreatedAsync();
|
|
||||||
|
|
||||||
var profileService = new DataCouplerProfileService(context);
|
|
||||||
|
|
||||||
// Test: Creazione e salvataggio di un profilo con SourceDatabaseName
|
|
||||||
var testProfile = new DataCouplerProfile
|
|
||||||
{
|
|
||||||
Name = "Test Profile DB",
|
|
||||||
Description = "Test per verificare il salvataggio del SourceDatabaseName",
|
|
||||||
SourceType = "database",
|
|
||||||
SourceDatabaseName = "MyProductionDatabase",
|
|
||||||
SourceSchema = "dbo",
|
|
||||||
SourceTable = "customers",
|
|
||||||
DestinationType = "rest",
|
|
||||||
DestinationEndpoint = "/api/customers",
|
|
||||||
CreatedBy = "TestUser"
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine($"📝 Creando profilo con SourceDatabaseName: {testProfile.SourceDatabaseName}");
|
|
||||||
|
|
||||||
// Salvataggio nel database
|
|
||||||
var savedProfile = await profileService.SaveProfileAsync(testProfile);
|
|
||||||
Console.WriteLine($"✅ Profilo salvato con ID: {savedProfile.Id}");
|
|
||||||
|
|
||||||
// Recupero dal database
|
|
||||||
var retrievedProfile = await profileService.GetProfileByIdAsync(savedProfile.Id);
|
|
||||||
Console.WriteLine($"✅ Profilo recuperato dal database");
|
|
||||||
|
|
||||||
// Verifica che il SourceDatabaseName sia stato salvato e recuperato correttamente
|
|
||||||
if (retrievedProfile != null && retrievedProfile.SourceDatabaseName == testProfile.SourceDatabaseName)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"✅ SUCCESSO: SourceDatabaseName salvato e recuperato correttamente: {retrievedProfile.SourceDatabaseName}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"❌ ERRORE: SourceDatabaseName non salvato correttamente");
|
|
||||||
Console.WriteLine($" Originale: {testProfile.SourceDatabaseName}");
|
|
||||||
Console.WriteLine($" Recuperato: {retrievedProfile?.SourceDatabaseName ?? "NULL"}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test conversione DTO
|
|
||||||
var dto = profileService.ToDto(retrievedProfile!);
|
|
||||||
Console.WriteLine($"✅ DTO convertito con SourceDatabaseName: {dto.SourceDatabaseName}");
|
|
||||||
|
|
||||||
// Pulizia
|
|
||||||
await context.Database.EnsureDeletedAsync();
|
|
||||||
Console.WriteLine("🧹 Database temporaneo eliminato");
|
|
||||||
|
|
||||||
Console.WriteLine("\n🎯 Test completato con successo!");
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<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