From 9d5cb4b5ea9dbb22aca7eef75ca637e0300c53d9 Mon Sep 17 00:00:00 2001 From: Mohammad Moattar Date: Wed, 31 Jan 2024 00:24:44 +0000 Subject: [PATCH] Fix the Tests --- .../Helpers/TestApplicationFactory.cs | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Samples/LittleBlocks.Sample.WebAPI.IntegrationTests/Helpers/TestApplicationFactory.cs b/src/Samples/LittleBlocks.Sample.WebAPI.IntegrationTests/Helpers/TestApplicationFactory.cs index 115fda0..b9dbc63 100644 --- a/src/Samples/LittleBlocks.Sample.WebAPI.IntegrationTests/Helpers/TestApplicationFactory.cs +++ b/src/Samples/LittleBlocks.Sample.WebAPI.IntegrationTests/Helpers/TestApplicationFactory.cs @@ -15,7 +15,7 @@ // along with this program. If not, see . using System.Net.Http; -using Serilog.AspNetCore; +using Microsoft.Extensions.Hosting; namespace LittleBlocks.Sample.WebAPI.IntegrationTests.Helpers; @@ -55,21 +55,24 @@ public string LogDirectoryPath return Path.Combine(path, logsDirectory); } } - - protected override IWebHostBuilder CreateWebHostBuilder() + + protected override IHostBuilder CreateHostBuilder() { - var hostBuilder = WebHost.CreateDefaultBuilder() - .ConfigureAppConfiguration((context, builder) => + var hostBuilder = Host.CreateDefaultBuilder() + .ConfigureWebHostDefaults(webHostBuilder => { - var env = context.HostingEnvironment; - env.EnvironmentName = _options.Environment; - - var configOptions = new ConfigurationOptions(env.ContentRootPath, env.EnvironmentName, - env.ApplicationName, new string[] { }); - builder.ConfigureBuilder(configOptions); - }) - .UseStartup() - .ConfigureServices(_options.ConfigureServices); + webHostBuilder.ConfigureAppConfiguration((context, builder) => + { + var env = context.HostingEnvironment; + env.EnvironmentName = _options.Environment; + + var configOptions = new ConfigurationOptions(env.ContentRootPath, env.EnvironmentName, + env.ApplicationName, new string[] { }); + builder.ConfigureBuilder(configOptions); + }) + .UseStartup() + .ConfigureServices(_options.ConfigureServices); + }); if (_options.EnableLoggingToFile) hostBuilder.UseSerilog((context, configuration) =>