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(); 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();