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

@ -14,7 +14,7 @@ public class UnitTestClientSettingsController
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
@ -22,7 +22,7 @@ public class UnitTestClientSettingsController
[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>>();
@ -34,7 +34,7 @@ public class UnitTestClientSettingsController
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IClientSettingsController<object>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
}
[TestMethod]
@ -47,7 +47,7 @@ public class UnitTestClientSettingsController
List<string>? clientSettings = clientSettingsRepository?.GetClientSettings(null);
Assert.IsTrue(clientSettings is not null);
#endif
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
}
#pragma warning disable CS1998
@ -67,7 +67,7 @@ public class UnitTestClientSettingsController
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
#endif
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
}
#pragma warning restore CS1998
@ -79,7 +79,7 @@ public class UnitTestClientSettingsController
IClientSettingsRepository? clientSettingsRepository = serviceProvider?.GetRequiredService<IClientSettingsRepository>();
string? ipAddress = clientSettingsRepository?.GetIpAddress(null);
Assert.IsTrue(ipAddress is not null);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
}
[TestMethod]
@ -95,7 +95,7 @@ public class UnitTestClientSettingsController
string json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetIpAddress)}.json"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
}
}