Ripulata cartella progetto
This commit is contained in:
@@ -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