Dynamic 5 and 14 point copy

AppSettings alignment with other projects

_TestContextTestName over _TestContext
This commit is contained in:
2025-05-02 15:22:18 -07:00
parent 2afb312065
commit 6f52566fc2
30 changed files with 415 additions and 326 deletions

View File

@ -15,7 +15,7 @@ public class UnitTestAppSettingsController
private static ILogger? _Logger;
private static string _ControllerName;
private static TestContext _TestContext;
private static string? _TestContextTestName;
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -23,7 +23,7 @@ public class UnitTestAppSettingsController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContext = testContext;
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -42,7 +42,7 @@ public class UnitTestAppSettingsController
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IAppSettingsController<object>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
NonThrowTryCatch();
}
@ -53,7 +53,7 @@ public class UnitTestAppSettingsController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
appSettingsRepository?.VerifyConnectionStrings();
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
NonThrowTryCatch();
}
@ -64,7 +64,7 @@ public class UnitTestAppSettingsController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
AppSettings? appSettings = serviceProvider?.GetRequiredService<AppSettings>();
Assert.IsNotNull(appSettings);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
NonThrowTryCatch();
}
@ -76,7 +76,7 @@ public class UnitTestAppSettingsController
IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
Server.Models.Binder.AppSettings? appSettings = appSettingsRepository?.GetAppSettings();
Assert.IsTrue(appSettings is not null);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
NonThrowTryCatch();
}
@ -94,7 +94,7 @@ public class UnitTestAppSettingsController
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAppSettings)}.json"), json);
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
NonThrowTryCatch();
}
@ -106,7 +106,7 @@ public class UnitTestAppSettingsController
IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
string? result = appSettingsRepository?.GetBuildNumberAndGitCommitSeven();
Assert.IsTrue(result is not null);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
NonThrowTryCatch();
}
@ -123,7 +123,7 @@ public class UnitTestAppSettingsController
string json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetBuildNumberAndGitCommitSeven)}.json"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
NonThrowTryCatch();
}