From 10c4a54566a0f33d0938eecbeb01d4d7b112c82a Mon Sep 17 00:00:00 2001 From: Ali Yousefi Date: Fri, 2 Feb 2024 00:25:28 +0330 Subject: [PATCH] Update config --- .../Fixtures/TestFixture.cs | 11 ++++++++--- .../appsettings.json | 5 +++++ .../appsettings.Development.json | 5 +++++ .../appsettings.json | 5 +++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/Fixtures/TestFixture.cs b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/Fixtures/TestFixture.cs index 39a619c..93f3a5a 100644 --- a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/Fixtures/TestFixture.cs +++ b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/Fixtures/TestFixture.cs @@ -7,6 +7,7 @@ using EasyMicroservices.TemplateGeneratorMicroservice.WebApi.Controllers; using Identity.GeneratedServices; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using TemplateGenerators.GeneratedServices; using Xunit; @@ -31,20 +32,24 @@ public static async Task StartAsync() { try { + IConfiguration config = new ConfigurationBuilder() + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .Build(); await Semaphore.WaitAsync(); if (DefaultServiceProvider != null) return DefaultServiceProvider; var app = Program.CreateBuilder(null); UnitOfWork.MapperTypeAssembly = typeof(ItemTypeDatabaseLogic); - string authBaseUrl = $"http://localhost:{2007}"; - string generatorBaseUrl = $"http://localhost:{1050}"; + string generatorBaseUrl = config.GetSection("Urls").Get().Replace("*", "localhost"); + string authBaseUrl = config.GetSection("ServiceAddresses").GetChildren().FirstOrDefault(x=>x.GetValue("Name") == "Authentication").GetValue("Address"); + string identityBaseUrl = config.GetSection("ServiceAddresses").GetChildren().FirstOrDefault(x=>x.GetValue("Name") == "Identity").GetValue("Address"); app.Services.AddSingleton(s => new HttpClient()); app.Services.AddTransient(s => new AuthenticationClient(authBaseUrl, s.GetService())); app.Services.AddTransient(s => new NoParentFormItemClient(generatorBaseUrl, s.GetService())); app.Services.AddTransient(s => new EventClient(generatorBaseUrl, s.GetService())); app.Services.AddTransient(s => new ActionClient(generatorBaseUrl, s.GetService())); app.Services.AddMvc().AddApplicationPart(typeof(FormController).Assembly); - + var build = await app.BuildWithUseCors(default, true); build.MapControllers(); var scope = build.Services.CreateScope(); diff --git a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/appsettings.json b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/appsettings.json index 3cd451e..ce1a426 100644 --- a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/appsettings.json +++ b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.Tests/appsettings.json @@ -28,6 +28,11 @@ "Name": "Content", "Address": "http://localhost:2003", "Databases": null + }, + { + "Name": "Identity", + "Address": "http://localhost:2007", + "Databases": null } ], "Authorization": { diff --git a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.Development.json b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.Development.json index 3cd451e..ce1a426 100644 --- a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.Development.json +++ b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.Development.json @@ -28,6 +28,11 @@ "Name": "Content", "Address": "http://localhost:2003", "Databases": null + }, + { + "Name": "Identity", + "Address": "http://localhost:2007", + "Databases": null } ], "Authorization": { diff --git a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.json b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.json index 3cd451e..ce1a426 100644 --- a/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.json +++ b/src/CSharp/EasyMicroservices.TemplateGeneratorMicroservice.WebApi/appsettings.json @@ -28,6 +28,11 @@ "Name": "Content", "Address": "http://localhost:2003", "Databases": null + }, + { + "Name": "Identity", + "Address": "http://localhost:2007", + "Databases": null } ], "Authorization": {