diff --git a/Static/js/site-server.js b/Static/js/site-server.js index 6f5fd4a..4b01557 100644 --- a/Static/js/site-server.js +++ b/Static/js/site-server.js @@ -1039,19 +1039,19 @@ function recipeParametersButtonRunInfo() { $.getJSON('https://oi-prod-ec-api.mes.infineon.com:4433/api/oiWizard/materials/rds/' + jsonObject.RDS, function (data) { $("#RecipeParametersButton").prop("disabled", false); var text = ""; - var seperator = '\t'; + var separator = '\t'; for (var i = 0; i < data.rds.rdsLayers.length; i++) { text = text + data.rds.rdsLayers[i].EpiTime - + seperator + data.rds.rdsLayers[i].EpiH2Flow - + seperator + data.rds.rdsLayers[i].TCSFlow - + seperator + data.rds.rdsLayers[i].DiluentAdjParam - + seperator + data.rds.rdsLayers[i].EpiH2Flow - + seperator + data.rds.rdsLayers[i].DopantFlow - + seperator + data.rds.rdsLayers[i].FOffset - + seperator + data.rds.rdsLayers[i].SOffset - + seperator + data.rds.rdsLayers[i].ROffset - + seperator + data.rds.rdsLayers[i].SuscEtch; + + separator + data.rds.rdsLayers[i].EpiH2Flow + + separator + data.rds.rdsLayers[i].TCSFlow + + separator + data.rds.rdsLayers[i].DiluentAdjParam + + separator + data.rds.rdsLayers[i].EpiH2Flow + + separator + data.rds.rdsLayers[i].DopantFlow + + separator + data.rds.rdsLayers[i].FOffset + + separator + data.rds.rdsLayers[i].SOffset + + separator + data.rds.rdsLayers[i].ROffset + + separator + data.rds.rdsLayers[i].SuscEtch; } $("#textareaClipboard").val(text); $("#ModalBodyGrid").igGrid({ @@ -1112,14 +1112,14 @@ function viewButtonRunInfo() { $.getJSON(detailsURL, function (data) { var obj = {}; var text = ""; - var seperator = jsonObject.RDS.length < 6 ? '\r' : '\t'; - for (var i = 0; i < data.Results.length && (jsonObject.RDS.length < 6 || i < 9); i++) { - if (data.Results[i].Thickness) { - text = text + data.Results[i].Thickness + seperator; + var separator = jsonObject.RDS.length < 6 ? '\r' : '\t'; + for (var i = 0; i < data.Results.length; i++) { + if (data.Results[i].Thickness && data.Results[i].Position && parseInt(data.Results[i].Position) > 0) { + text = text + data.Results[i].Thickness + separator; obj['Point' + (i + 1)] = data.Results[i].Thickness; } - else if (data.Results[i].Rs) { - text = text + data.Results[i].Rs + seperator; + else if (data.Results[i].Rs && data.Results[i].Position && parseInt(data.Results[i].Position) > 0) { + text = text + data.Results[i].Rs + separator; obj['Point' + (i + 1)] = data.Results[i].Rs; } } @@ -1191,18 +1191,18 @@ function pinButtonRunInfo() { responseDataKey: "Results", }); var text = ""; - var seperator = '\t'; + var separator = '\t'; for (var i = 0; i < data.Results.length; i++) { text = text + data.Results[i].Point1 - + seperator + data.Results[i].Point2 - + seperator + data.Results[i].Point3 - + seperator + data.Results[i].Point4 - + seperator + data.Results[i].Point5 - + seperator + data.Results[i].Point6 - + seperator + data.Results[i].Point7 - + seperator + data.Results[i].Point8 - + seperator + data.Results[i].Point9; + + separator + data.Results[i].Point2 + + separator + data.Results[i].Point3 + + separator + data.Results[i].Point4 + + separator + data.Results[i].Point5 + + separator + data.Results[i].Point6 + + separator + data.Results[i].Point7 + + separator + data.Results[i].Point8 + + separator + data.Results[i].Point9; } $("#textareaClipboard").val(text); $("#ModalBodyGrid").igGrid({ diff --git a/Tests/.vscode/tc_col_metrology-viewer-dev.http b/Tests/.vscode/tc_col_metrology-viewer-dev.http new file mode 100644 index 0000000..0739380 --- /dev/null +++ b/Tests/.vscode/tc_col_metrology-viewer-dev.http @@ -0,0 +1,11 @@ +### +POST http://localhost:5126/api/inbound/cde +Accept: application/json + +### +GET http://localhost:5126/api/export/headers +Accept: application/json + +### +POST http://localhost:5003/api/inbound/SRP +Accept: application/json diff --git a/Tests/.vscode/tc_col_metrology-viewer-v1.http b/Tests/.vscode/tc_col_metrology-viewer-v1.http new file mode 100644 index 0000000..47ccb2d --- /dev/null +++ b/Tests/.vscode/tc_col_metrology-viewer-v1.http @@ -0,0 +1,5 @@ +@host = https://oi-metrology-viewer-prod.mes.infineon.com:4432/api/v1 + +### +GET {{host}}/WaferCounter/8INCH/last-quantity-and-slot-map/?area=MU +Accept: application/json diff --git a/Tests/.vscode/tc_col_metrology-viewer-v2.http b/Tests/.vscode/tc_col_metrology-viewer-v2.http new file mode 100644 index 0000000..d98d4c8 --- /dev/null +++ b/Tests/.vscode/tc_col_metrology-viewer-v2.http @@ -0,0 +1,21 @@ +@host = https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV2 + +### +GET {{host}}/1677273357/header +Accept: application/json + +### +GET {{host}}/1677273357/events +Accept: application/json + +### +GET {{host}}/1677273357/descriptors +Accept: application/json + +### +GET {{host}}/1677273357/data +Accept: application/json + +### +GET {{host}}/1677273357/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 14:15:00 +Accept: application/json diff --git a/Tests/.vscode/tc_col_metrology-viewer-v3.http b/Tests/.vscode/tc_col_metrology-viewer-v3.http new file mode 100644 index 0000000..8d6238a --- /dev/null +++ b/Tests/.vscode/tc_col_metrology-viewer-v3.http @@ -0,0 +1,17 @@ +@host = https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV3 + +### +GET {{host}}/61/product-data-average-sum-of-defects-process-mean-process-sigma?recipe=8IN_IFX_ROTR +Accept: application/json + +### +GET {{host}}/epi-pro-temp-verificatio +Accept: application/json + +### +GET {{host}}/epi-pro-temp-verification-row +Accept: application/json + +### +GET {{host}}/111/header +Accept: application/json diff --git a/Tests/.vscode/tc_col_metrology-viewer-v4.http b/Tests/.vscode/tc_col_metrology-viewer-v4.http new file mode 100644 index 0000000..08f3907 --- /dev/null +++ b/Tests/.vscode/tc_col_metrology-viewer-v4.http @@ -0,0 +1,32 @@ +@host = http://metrology-viewer-prod.mes.infineon.com:5002/api/v4/InfinityQS +@hostB = https://oi-metrology-viewer-prod.mes.infineon.com:4435/api/v4/InfinityQS +@hostE = https://oi-metrology-viewer-prod.mes.infineon.com:4433/api/t1ooltypes +@hostF = https://oi-metrology-viewer-prod.mes.infineon.com:4433/api/v4/InfinityQS + +### +GET {{host}}/reactors +Accept: application/json + +### +GET {{host}}/4589/production-specification +Accept: application/json + +### +GET {{host}}/engineering-spc-review +Accept: application/json + +### +GET {{hostB}}/58/last-group-id-with-value/?part=4840&test=1228920625 +Accept: application/json + +### +GET {{hostE}}/-1/headertitles +Accept: application/json + +### +GET {{hostF}}/epi-pro-temp-verification +Accept: text/html + +### +GET {{hostF}}/epi-pro-temp-verification-rows +Accept: application/json diff --git a/Tests/.vscode/tc_col_metrology-viewer.http b/Tests/.vscode/tc_col_metrology-viewer.http new file mode 100644 index 0000000..3c6a094 --- /dev/null +++ b/Tests/.vscode/tc_col_metrology-viewer.http @@ -0,0 +1,51 @@ +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/tooltypes +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/export/export +Accept: application/json + +### +POST http://oi-metrology-viewer-prod.mes.infineon.com/api/inbound/SRP +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/export/pdsf +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/export/logistics +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/export/logistics +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/export/headers +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/header +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/events +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/descriptors +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/1677273357/data +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQS/commandText/?sub_group_id=1677273357&process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 14:15:00 +Accept: application/json + +### +GET https://oi-metrology-viewer-prod.mes.infineon.com:4436/api/AppSettings/App +Accept: application/json diff --git a/Tests/.vscode/wafer-counter.http b/Tests/.vscode/wafer-counter.http new file mode 100644 index 0000000..b2b3ead --- /dev/null +++ b/Tests/.vscode/wafer-counter.http @@ -0,0 +1,23 @@ + +@host = https://oi-metrology-viewer-prod.mes.infineon.com:4438/api/v1/file-share/archive-data/?area=FQA&equipment-id=FQA-8INCH&search-pattern=*.wc&wafer-size=8INCH +@hostB = https://oi-metrology-viewer-prod.mes.infineon.com:4437/api/v1 +@hostC = https://oi-metrology-viewer-prod.mes.infineon.com:4438/api/v1 +@waferSize = 6INCH +@area = FQA +@cassID = Test + +### +GET {{host}}/archive-data/?area=FQA&equipment-id=FQA-8INCH&search-pattern=*.wc&wafer-size=8INCH +Accept: application/json + +### +GET {{host}}/archive-data/?area=FQA&equipment-id=FQA-8INCH&search-pattern=*.wc&wafer-size=8INCH +Accept: application/json + +### +GET {{hostC}}/WaferCounter/{{waferSize}}/last-quantity-and-slot-map/?area={{area}}&text={{cassID}} +Accept: application/json + +### +GET {{hostB}}/file-share/equipment-ids +Accept: application/json \ No newline at end of file diff --git a/Tests/UnitAwaitingDispoController.cs b/Tests/UnitAwaitingDispoController.cs index 117821f..ddfdeda 100644 --- a/Tests/UnitAwaitingDispoController.cs +++ b/Tests/UnitAwaitingDispoController.cs @@ -15,7 +15,7 @@ public class UnitAwaitingDispoController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,7 +23,7 @@ public class UnitAwaitingDispoController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -35,7 +35,7 @@ public class UnitAwaitingDispoController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IAwaitingDispoController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -47,7 +47,7 @@ public class UnitAwaitingDispoController IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); IEnumerable? awaitingDispositions = metrologyRepository?.GetAwaitingDisposition(); Assert.IsTrue(awaitingDispositions is not null); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -59,7 +59,7 @@ public class UnitAwaitingDispoController Assert.IsTrue(httpClient is not null); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(IMetrologyRepository.GetAwaitingDisposition)}Api.json"), json); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -70,7 +70,7 @@ public class UnitAwaitingDispoController IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); _ = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: false); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -81,7 +81,7 @@ public class UnitAwaitingDispoController _Logger?.LogInformation("Starting Web Application"); Assert.IsTrue(httpClient is not null); _ = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/markasreviewed"); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -93,7 +93,7 @@ public class UnitAwaitingDispoController IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); int? dateCleared = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: true); Assert.IsTrue(dateCleared <= 1); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -104,7 +104,7 @@ public class UnitAwaitingDispoController _Logger?.LogInformation("Starting Web Application"); Assert.IsTrue(httpClient is not null); _ = await httpClient.PostAsync($"api/{_ControllerName}/markasawaiting", null); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -115,7 +115,7 @@ public class UnitAwaitingDispoController IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); Guid? guid = metrologyRepository?.GetHeaderAttachmentID(toolTypeId: 1, headerId: 1); Assert.IsNotNull(guid); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -126,7 +126,7 @@ public class UnitAwaitingDispoController Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/1/header-attachment-id?headerid=1"); Assert.IsNotNull(httpResponseMessage.Content); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } } \ No newline at end of file diff --git a/Tests/UnitInboundController.cs b/Tests/UnitInboundController.cs index b311b7b..e15d4e6 100644 --- a/Tests/UnitInboundController.cs +++ b/Tests/UnitInboundController.cs @@ -15,7 +15,7 @@ public class UnitInboundController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -23,7 +23,7 @@ public class UnitInboundController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -42,7 +42,7 @@ public class UnitInboundController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IInboundController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -60,7 +60,7 @@ public class UnitInboundController _Logger?.LogInformation("Starting Web Application"); Assert.IsTrue(httpClient is not null); _ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad", GetStringContent()); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -72,7 +72,7 @@ public class UnitInboundController _Logger?.LogInformation("Starting Web Application"); Assert.IsTrue(httpClient is not null); _ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad/attachment", GetStringContent()); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestAppSettingsController.cs b/Tests/UnitTestAppSettingsController.cs index e48193d..d98ce3f 100644 --- a/Tests/UnitTestAppSettingsController.cs +++ b/Tests/UnitTestAppSettingsController.cs @@ -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? _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(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -42,7 +42,7 @@ public class UnitTestAppSettingsController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IAppSettingsController.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? appSettingsRepository = serviceProvider?.GetRequiredService>(); 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(); Assert.IsNotNull(appSettings); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -76,7 +76,7 @@ public class UnitTestAppSettingsController IAppSettingsRepository? appSettingsRepository = serviceProvider?.GetRequiredService>(); 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? appSettingsRepository = serviceProvider?.GetRequiredService>(); 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(); } diff --git a/Tests/UnitTestClientSettingsController.cs b/Tests/UnitTestClientSettingsController.cs index 18b5483..a307a6a 100644 --- a/Tests/UnitTestClientSettingsController.cs +++ b/Tests/UnitTestClientSettingsController.cs @@ -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? _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(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -34,7 +34,7 @@ public class UnitTestClientSettingsController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IClientSettingsController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -47,7 +47,7 @@ public class UnitTestClientSettingsController List? 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(); 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); } } \ No newline at end of file diff --git a/Tests/UnitTestExportController.cs b/Tests/UnitTestExportController.cs index 7e6bc80..47c60f7 100644 --- a/Tests/UnitTestExportController.cs +++ b/Tests/UnitTestExportController.cs @@ -16,7 +16,7 @@ public class UnitTestExportController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -24,7 +24,7 @@ public class UnitTestExportController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -43,7 +43,7 @@ public class UnitTestExportController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IExportController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -61,7 +61,7 @@ public class UnitTestExportController IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); string? result = exportRepository?.GetExport(GetHeaderCommon()); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -74,7 +74,7 @@ public class UnitTestExportController string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/export"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -86,7 +86,7 @@ public class UnitTestExportController Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -98,7 +98,7 @@ public class UnitTestExportController IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); Result? result = exportRepository?.GetHeaders(GetHeaderCommon()); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -112,7 +112,7 @@ public class UnitTestExportController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -124,7 +124,7 @@ public class UnitTestExportController Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -136,7 +136,7 @@ public class UnitTestExportController IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); Result? result = exportRepository?.GetLogistics(GetHeaderCommon()); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -150,7 +150,7 @@ public class UnitTestExportController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLogistics)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -162,7 +162,7 @@ public class UnitTestExportController Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -174,7 +174,7 @@ public class UnitTestExportController IExportRepository? exportRepository = serviceProvider?.GetRequiredService(); string? result = exportRepository?.GetProcessDataStandardFormat(GetHeaderCommon()); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -187,7 +187,7 @@ public class UnitTestExportController string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/processDataStandardFormat"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -199,7 +199,7 @@ public class UnitTestExportController Assert.IsTrue(httpClient is not null); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -215,7 +215,7 @@ public class UnitTestExportController Result? result = exportRepository?.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -230,7 +230,7 @@ public class UnitTestExportController Result? result = Newtonsoft.Json.JsonConvert.DeserializeObject>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -243,7 +243,7 @@ public class UnitTestExportController Assert.IsTrue(metrologyRepository is not null); string? result = exportRepository?.GetCSVExport(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -256,7 +256,7 @@ public class UnitTestExportController string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/1/csv?datebegin=&dateend="); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCSVExport)}.csv"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } } \ No newline at end of file diff --git a/Tests/UnitTestFileShareController.cs b/Tests/UnitTestFileShareController.cs index 5b575c9..7058f69 100644 --- a/Tests/UnitTestFileShareController.cs +++ b/Tests/UnitTestFileShareController.cs @@ -16,7 +16,7 @@ public class UnitTestFileShareController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -24,7 +24,7 @@ public class UnitTestFileShareController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -44,7 +44,7 @@ public class UnitTestFileShareController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IFileShareController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -57,7 +57,7 @@ public class UnitTestFileShareController Assert.IsTrue(httpClient is not null); string? response = await httpClient.GetStringAsync($"api/v1/file-share/copy-file/?from=\\\\mesfs.infineon.com\\EC_Metrology_Si\\MetrologyAttachments\\CDERunHeader_\\2024\\WW11\\247233\\CDE5_240315162756858.pdsf&to=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\a.pdsf"); Assert.IsNotNull(response); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -70,7 +70,7 @@ public class UnitTestFileShareController Assert.IsTrue(httpClient is not null); string? response = await httpClient.GetStringAsync($"api/v1/file-share/move-file/?from=\\\\mesfs.infineon.com\\EC_Metrology_Si\\MetrologyAttachments\\CDERunHeader_\\2024\\WW11\\247233\\CDE5_240315162756858.pdsf&to=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\a.pdsf"); Assert.IsNotNull(response); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -82,7 +82,7 @@ public class UnitTestFileShareController Assert.IsTrue(httpClient is not null); string? response = await httpClient.GetStringAsync($"api/v1/file-share/file-write/?path=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\b.pdsf&contents=b"); Assert.IsNotNull(response); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -103,7 +103,7 @@ public class UnitTestFileShareController characterizationParameters = new(string.Empty, "CDE5", "CDE*.json", null, null, "8INCH"); result = fileShareRepository?.GetArchiveData(characterizationParameters); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -115,7 +115,7 @@ public class UnitTestFileShareController Assert.IsTrue(httpClient is not null); string? response = await httpClient.GetStringAsync($"api/v1/file-share/archive-data/?area=FQA&equipment-id=FQA-8INCH&search-pattern=*.wc&wafer-size=8INCH"); Assert.IsNotNull(response); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -127,7 +127,7 @@ public class UnitTestFileShareController IFileShareRepository? fileShareRepository = serviceProvider?.GetRequiredService(); ReadOnlyCollection? result = fileShareRepository?.GetEquipmentIds(); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -139,7 +139,7 @@ public class UnitTestFileShareController Assert.IsTrue(httpClient is not null); string? response = await httpClient.GetStringAsync($"api/v1/file-share/equipment-ids"); Assert.IsNotNull(response); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestISpreadingResistanceProfileController.cs b/Tests/UnitTestISpreadingResistanceProfileController.cs index 340b716..6aa41f8 100644 --- a/Tests/UnitTestISpreadingResistanceProfileController.cs +++ b/Tests/UnitTestISpreadingResistanceProfileController.cs @@ -13,7 +13,7 @@ public class UnitTestISpreadingResistanceProfileController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -21,7 +21,7 @@ public class UnitTestISpreadingResistanceProfileController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -40,7 +40,7 @@ public class UnitTestISpreadingResistanceProfileController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(ISpreadingResistanceProfileController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -62,7 +62,7 @@ public class UnitTestISpreadingResistanceProfileController Assert.IsTrue(bytes.Length != 0); File.WriteAllBytes(Path.Combine(directory, "srp.png"), bytes); } - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestInfinityQSController.cs b/Tests/UnitTestInfinityQSController.cs index 542ea9a..bbd7c0b 100644 --- a/Tests/UnitTestInfinityQSController.cs +++ b/Tests/UnitTestInfinityQSController.cs @@ -14,7 +14,7 @@ public class UnitTestInfinityQSController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -22,7 +22,7 @@ public class UnitTestInfinityQSController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -41,7 +41,7 @@ public class UnitTestInfinityQSController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IInfinityQSController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -56,7 +56,7 @@ public class UnitTestInfinityQSController IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService(); string? result = infinityQSRepository?.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -72,7 +72,7 @@ public class UnitTestInfinityQSController string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/commandText/?sub_group_id=1677273357&process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -93,7 +93,7 @@ public class UnitTestInfinityQSController Assert.IsNotNull(result?.Results[0].SE_TSNO); Assert.IsNotNull(result?.Results[0].TD_NAME); Assert.IsNotNull(result?.Results[0].TD_TEST); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -111,7 +111,7 @@ public class UnitTestInfinityQSController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -129,7 +129,7 @@ public class UnitTestInfinityQSController Assert.IsTrue(result?.Results.Length != 0); Assert.IsNotNull(result?.Results[0].SD_SGRP); Assert.IsNotNull(result?.Results[0].SD_TSNO); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -147,7 +147,7 @@ public class UnitTestInfinityQSController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -162,7 +162,7 @@ public class UnitTestInfinityQSController IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService(); Result? result = infinityQSRepository?.GetEvents("1677273357"); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -179,7 +179,7 @@ public class UnitTestInfinityQSController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEvents)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -194,7 +194,7 @@ public class UnitTestInfinityQSController IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService(); Result? result = infinityQSRepository?.GetHeader("1677273357"); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -211,7 +211,7 @@ public class UnitTestInfinityQSController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestInfinityQSV2Controller.cs b/Tests/UnitTestInfinityQSV2Controller.cs index f372bcf..c302a31 100644 --- a/Tests/UnitTestInfinityQSV2Controller.cs +++ b/Tests/UnitTestInfinityQSV2Controller.cs @@ -14,7 +14,7 @@ public class UnitTestInfinityQSV2Controller private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -22,7 +22,7 @@ public class UnitTestInfinityQSV2Controller [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -41,7 +41,7 @@ public class UnitTestInfinityQSV2Controller { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IInfinityQSV2Controller.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -53,7 +53,7 @@ public class UnitTestInfinityQSV2Controller IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV2Repository?.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -69,7 +69,7 @@ public class UnitTestInfinityQSV2Controller string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -90,7 +90,7 @@ public class UnitTestInfinityQSV2Controller Assert.IsNotNull(result?.Results[0].SiteNumber); Assert.IsNotNull(result?.Results[0].VariableNumber); Assert.IsNotNull(result?.Results[0].SubGroupDateTime); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -108,7 +108,7 @@ public class UnitTestInfinityQSV2Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -126,7 +126,7 @@ public class UnitTestInfinityQSV2Controller Assert.IsTrue(result?.Results.Length != 0); Assert.IsNotNull(result?.Results[0].SubGroupId); Assert.IsNotNull(result?.Results[0].SiteNumber); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -144,7 +144,7 @@ public class UnitTestInfinityQSV2Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -159,7 +159,7 @@ public class UnitTestInfinityQSV2Controller IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService(); Result? result = infinityQSV2Repository?.GetEvents("1677273357"); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -176,7 +176,7 @@ public class UnitTestInfinityQSV2Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEvents)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -192,7 +192,7 @@ public class UnitTestInfinityQSV2Controller Result? result = infinityQSV2Repository?.GetHeader("1677273357"); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results[0].Part); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -210,7 +210,7 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results[0].Part); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestInfinityQSV3Controller.cs b/Tests/UnitTestInfinityQSV3Controller.cs index 67fd39b..24cf8e2 100644 --- a/Tests/UnitTestInfinityQSV3Controller.cs +++ b/Tests/UnitTestInfinityQSV3Controller.cs @@ -14,7 +14,7 @@ public class UnitTestInfinityQSV3Controller private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -22,7 +22,7 @@ public class UnitTestInfinityQSV3Controller [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -41,7 +41,7 @@ public class UnitTestInfinityQSV3Controller { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IInfinityQSV3Controller.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -53,7 +53,7 @@ public class UnitTestInfinityQSV3Controller IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV3Repository?.GetCommandText("1698497987", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -66,7 +66,7 @@ public class UnitTestInfinityQSV3Controller string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -84,7 +84,7 @@ public class UnitTestInfinityQSV3Controller Assert.IsNotNull(result?.Results[0].SiteNumber); Assert.IsNotNull(result?.Results[0].VariableNumber); Assert.IsNotNull(result?.Results[0].SubGroupDateTime); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -99,7 +99,7 @@ public class UnitTestInfinityQSV3Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -114,7 +114,7 @@ public class UnitTestInfinityQSV3Controller Assert.IsTrue(result?.Results.Length != 0); Assert.IsNotNull(result?.Results[0].SubGroupId); Assert.IsNotNull(result?.Results[0].SiteNumber); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -129,7 +129,7 @@ public class UnitTestInfinityQSV3Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -142,7 +142,7 @@ public class UnitTestInfinityQSV3Controller Result? result = infinityQSV3Repository?.GetHeader("1698497987"); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results[0].Part); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -157,7 +157,7 @@ public class UnitTestInfinityQSV3Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results[0].Part); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -169,7 +169,7 @@ public class UnitTestInfinityQSV3Controller IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV3Repository?.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma("41", "8IN_THIN ROTR"); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -182,7 +182,7 @@ public class UnitTestInfinityQSV3Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/41/product-data-average-sum-of-defects-process-mean-process-sigma?recipe=8IN_THIN ROTR"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProductDataAverageSumOfDefectsProcessMeanProcessSigma)}.json"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -195,7 +195,7 @@ public class UnitTestInfinityQSV3Controller IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); List? results = infinityQSV3Repository?.GetEpiProTempVerificationRows(night); Assert.IsNotNull(results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -208,7 +208,7 @@ public class UnitTestInfinityQSV3Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/epi-pro-temp-verification-rows/?night=44&night=46&night=52&night=54"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerificationRows)}.json"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -221,7 +221,7 @@ public class UnitTestInfinityQSV3Controller IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV3Repository?.GetEpiProTempVerification(night); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -234,7 +234,7 @@ public class UnitTestInfinityQSV3Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/epi-pro-temp-verification/?night=44&night=46&night=52&night=54"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerification)}.html"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestInfinityQSV4Controller.cs b/Tests/UnitTestInfinityQSV4Controller.cs index de9a2d3..1c95b73 100644 --- a/Tests/UnitTestInfinityQSV4Controller.cs +++ b/Tests/UnitTestInfinityQSV4Controller.cs @@ -15,7 +15,7 @@ public class UnitTestInfinityQSV4Controller private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static string _ControllerVersion; private static WebApplicationFactory? _WebApplicationFactory; @@ -24,7 +24,7 @@ public class UnitTestInfinityQSV4Controller [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -45,7 +45,7 @@ public class UnitTestInfinityQSV4Controller _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IInfinityQSV4Controller.GetRouteName(), _ControllerName); Assert.AreEqual(IInfinityQSV4Controller.GetRouteVersion(), _ControllerVersion); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -57,7 +57,7 @@ public class UnitTestInfinityQSV4Controller IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV4Repository?.GetCommandText("1718539249", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -70,7 +70,7 @@ public class UnitTestInfinityQSV4Controller string? json = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/1718539249/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -88,7 +88,7 @@ public class UnitTestInfinityQSV4Controller Assert.IsNotNull(result?.Results[0].SiteNumber); Assert.IsNotNull(result?.Results[0].VariableNumber); Assert.IsNotNull(result?.Results[0].SubGroupDateTime); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -103,7 +103,7 @@ public class UnitTestInfinityQSV4Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -118,7 +118,7 @@ public class UnitTestInfinityQSV4Controller Assert.IsTrue(result?.Results.Length != 0); Assert.IsNotNull(result?.Results[0].SubGroupId); Assert.IsNotNull(result?.Results[0].SiteNumber); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -133,7 +133,7 @@ public class UnitTestInfinityQSV4Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -146,7 +146,7 @@ public class UnitTestInfinityQSV4Controller Result? result = infinityQSV4Repository?.GetHeader("1718539249"); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results[0].Part); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -161,7 +161,7 @@ public class UnitTestInfinityQSV4Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results[0].Part); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -173,7 +173,7 @@ public class UnitTestInfinityQSV4Controller IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV4Repository?.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma("41", "8IN_THIN ROTR"); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -186,7 +186,7 @@ public class UnitTestInfinityQSV4Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/41/product-data-average-sum-of-defects-process-mean-process-sigma?recipe=8IN_THIN ROTR"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProductDataAverageSumOfDefectsProcessMeanProcessSigma)}.json"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -199,7 +199,7 @@ public class UnitTestInfinityQSV4Controller IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService(); List? results = infinityQSV4Repository?.GetEpiProTempVerificationRows(night); Assert.IsNotNull(results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -212,7 +212,7 @@ public class UnitTestInfinityQSV4Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/epi-pro-temp-verification-rows/?night=44&night=46&night=52&night=54"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerificationRows)}.json"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -225,7 +225,7 @@ public class UnitTestInfinityQSV4Controller IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV4Repository?.GetEpiProTempVerification(night); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -238,7 +238,7 @@ public class UnitTestInfinityQSV4Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/epi-pro-temp-verification/?night=44&night=46&night=52&night=54"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerification)}.html"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -250,7 +250,7 @@ public class UnitTestInfinityQSV4Controller IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService(); List? results = infinityQSV4Repository?.GetReactors(); Assert.IsNotNull(results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -266,7 +266,7 @@ public class UnitTestInfinityQSV4Controller result = infinityQSV4Repository?.GetProductionSpecification(part); Assert.IsNotNull(result); } - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -298,7 +298,7 @@ public class UnitTestInfinityQSV4Controller result = infinityQSV4Repository?.GetProductionSpecification(part); Assert.IsNotNull(result); } - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -313,7 +313,7 @@ public class UnitTestInfinityQSV4Controller IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService(); string? result = infinityQSV4Repository?.GetLastGroupIdWithValue(process, part, test); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -329,7 +329,7 @@ public class UnitTestInfinityQSV4Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/{process}/last-group-id-with-value/?part={part}&test={test}"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLastGroupIdWithValue)}.html"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestOpenInsightV1Controller.cs b/Tests/UnitTestOpenInsightV1Controller.cs index a2ff8d7..742d340 100644 --- a/Tests/UnitTestOpenInsightV1Controller.cs +++ b/Tests/UnitTestOpenInsightV1Controller.cs @@ -13,7 +13,7 @@ public class UnitTestOpenInsightV1Controller private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -21,7 +21,7 @@ public class UnitTestOpenInsightV1Controller [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -40,7 +40,7 @@ public class UnitTestOpenInsightV1Controller { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IOpenInsightV1Controller.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -51,7 +51,7 @@ public class UnitTestOpenInsightV1Controller IOpenInsightV1Repository? openInsightRepository = serviceProvider?.GetRequiredService(); string? result = openInsightRepository?.GetTencorRun("615071", "10/30/2023 06:48:34PM", "6IN_EPP ROTR"); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -64,7 +64,7 @@ public class UnitTestOpenInsightV1Controller string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/615071/tencor-run?insert_date=10/30/2023 06:48:34PM&recipe=6IN_EPP ROTR"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetTencorRun)}.json"), result); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Tests/UnitTestPinController.cs b/Tests/UnitTestPinController.cs index cfc947d..d861b00 100644 --- a/Tests/UnitTestPinController.cs +++ b/Tests/UnitTestPinController.cs @@ -14,7 +14,7 @@ public class UnitTestPinController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -22,7 +22,7 @@ public class UnitTestPinController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -34,7 +34,7 @@ public class UnitTestPinController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IPinController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -44,10 +44,10 @@ public class UnitTestPinController IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider; IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService(); IPinRepository? pinRepository = serviceProvider?.GetRequiredService(); - Assert.IsTrue(metrologyRepository is not null); + Assert.IsNotNull(metrologyRepository); Result? result = pinRepository?.GetPinnedTable(metrologyRepository, id: 1, cde_id: null, biorad_id: null, rds: null); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -55,12 +55,12 @@ public class UnitTestPinController { HttpClient? httpClient = _WebApplicationFactory?.CreateClient(); _Logger?.LogInformation("Starting Web Application"); - Assert.IsTrue(httpClient is not null); + Assert.IsNotNull(httpClient); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/pinned"); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetPinnedTable)}.json"), json); Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } } \ No newline at end of file diff --git a/Tests/UnitTestServiceShopOrderController.cs b/Tests/UnitTestServiceShopOrderController.cs index ffc2a7e..2571683 100644 --- a/Tests/UnitTestServiceShopOrderController.cs +++ b/Tests/UnitTestServiceShopOrderController.cs @@ -14,7 +14,7 @@ public class UnitTestServiceShopOrderController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -22,7 +22,7 @@ public class UnitTestServiceShopOrderController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -34,7 +34,7 @@ public class UnitTestServiceShopOrderController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IServiceShopOrderController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -44,7 +44,7 @@ public class UnitTestServiceShopOrderController throw new NullReferenceException(nameof(_Logger)); ServiceShopOrder[] serviceShopOrders = IServiceShopOrder.GetServiceShopOrders(null); Assert.IsNotNull(serviceShopOrders); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -60,7 +60,7 @@ public class UnitTestServiceShopOrderController serviceShopOrders = await serviceShopOrderRepository.GetServiceShopOrders("23188d3d-9b75-ed11-ab8b-0050568f2fc3"); Assert.IsTrue(serviceShopOrders is not null && serviceShopOrders.Length != 0); Assert.IsNotNull(serviceShopOrders[0].ToString()); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -75,7 +75,7 @@ public class UnitTestServiceShopOrderController ServiceShopOrder[]? serviceShopOrders = System.Text.Json.JsonSerializer.Deserialize(json); Assert.IsNotNull(serviceShopOrders); Assert.IsTrue(serviceShopOrders.Length != 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } } \ No newline at end of file diff --git a/Tests/UnitTestToolTypesController.cs b/Tests/UnitTestToolTypesController.cs index b82fec4..eb6f64f 100644 --- a/Tests/UnitTestToolTypesController.cs +++ b/Tests/UnitTestToolTypesController.cs @@ -17,7 +17,7 @@ public class UnitTestToolTypesController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -25,7 +25,7 @@ public class UnitTestToolTypesController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -44,7 +44,7 @@ public class UnitTestToolTypesController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IToolTypesController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -59,7 +59,7 @@ public class UnitTestToolTypesController Assert.IsNotNull(result?.Results); Assert.IsTrue(result.Results.Length != 0); Assert.IsFalse(result.Results.All(l => l.ID == 0)); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -74,7 +74,7 @@ public class UnitTestToolTypesController Assert.IsNotNull(result?.Results); Assert.IsTrue(result.Results.Length != 0); Assert.IsFalse(result.Results.All(l => l.ID == 0)); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -90,7 +90,7 @@ public class UnitTestToolTypesController Assert.IsNotNull(result.Results.Metadata); Assert.IsTrue(result.Results.Metadata.Length != 0); Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0)); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -106,7 +106,7 @@ public class UnitTestToolTypesController Assert.IsNotNull(result.Results.Metadata); Assert.IsTrue(result.Results.Metadata.Length != 0); Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0)); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -120,7 +120,7 @@ public class UnitTestToolTypesController Result? result = toolTypesRepository?.GetHeaders(metrologyRepository, id: 1, datebegin: null, dateend: null, page: null, pagesize: null, headerid: null); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -134,7 +134,7 @@ public class UnitTestToolTypesController Result? result = Newtonsoft.Json.JsonConvert.DeserializeObject>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -148,7 +148,7 @@ public class UnitTestToolTypesController Result? result = toolTypesRepository?.GetHeaderTitles(metrologyRepository, id: -1, page: null, pagesize: null); Assert.IsNotNull(result?.Results); Assert.IsTrue(result?.Results.Length != 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -162,7 +162,7 @@ public class UnitTestToolTypesController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); Assert.IsTrue(result.Results.Length != 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -176,7 +176,7 @@ public class UnitTestToolTypesController Result? result = toolTypesRepository?.GetHeaderFields(metrologyRepository, id: 1, headerid: 1); Assert.IsNotNull(result?.Results); Assert.IsTrue(result.Results.Length != 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -190,7 +190,7 @@ public class UnitTestToolTypesController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); Assert.IsTrue(result.Results.Length != 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -204,7 +204,7 @@ public class UnitTestToolTypesController Result? result = toolTypesRepository?.GetData(metrologyRepository, id: 1, headerid: 1); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [TestMethod] @@ -218,7 +218,7 @@ public class UnitTestToolTypesController Result? result = Newtonsoft.Json.JsonConvert.DeserializeObject>(json); Assert.IsNotNull(result?.Results); Assert.IsNotNull(result.Results.Rows.Count > 0); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -239,7 +239,7 @@ public class UnitTestToolTypesController Assert.IsTrue(toolTypesRepository is not null); (string? message, string? _, Stream? _) = toolTypesRepository.GetAttachment(metrologyRepository, attachmentsService, toolTypeId, tabletype, attachmentId, filename); Assert.IsTrue(message is null); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -250,7 +250,7 @@ public class UnitTestToolTypesController _Logger?.LogInformation("Starting Web Application"); Assert.IsTrue(httpClient is not null); _ = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/1/data/files/ffdf5410-ca19-4097-bfa4-b398e236d07e/data.txt"); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -268,7 +268,7 @@ public class UnitTestToolTypesController Assert.IsTrue(metrologyRepository is not null); string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, toolTypeId: 1, headerid: 1); Assert.IsTrue(message is null); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } [Ignore] @@ -279,7 +279,7 @@ public class UnitTestToolTypesController _Logger?.LogInformation("Starting Web Application"); Assert.IsTrue(httpClient is not null); _ = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/1/headers/1/export"); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); } } \ No newline at end of file diff --git a/Tests/UnitTestWaferCounterController.cs b/Tests/UnitTestWaferCounterController.cs index 936e601..98cfcc4 100644 --- a/Tests/UnitTestWaferCounterController.cs +++ b/Tests/UnitTestWaferCounterController.cs @@ -14,7 +14,7 @@ public class UnitTestWaferCounterController private static ILogger? _Logger; private static string _ControllerName; - private static TestContext _TestContext; + private static string? _TestContextTestName; private static WebApplicationFactory? _WebApplicationFactory; #pragma warning restore @@ -22,7 +22,7 @@ public class UnitTestWaferCounterController [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { - _TestContext = testContext; + _TestContextTestName = testContext.TestName; _WebApplicationFactory = new WebApplicationFactory(); IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider; _Logger = serviceProvider.GetRequiredService>(); @@ -41,7 +41,7 @@ public class UnitTestWaferCounterController { _Logger?.LogInformation("Starting Web Application"); Assert.AreEqual(IFileShareController.GetRouteName(), _ControllerName); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -54,7 +54,7 @@ public class UnitTestWaferCounterController IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService(); WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap(area: "FQA", waferSize: "8INCH", text: "Test"); Assert.IsNotNull(result); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } @@ -67,7 +67,7 @@ public class UnitTestWaferCounterController Assert.IsTrue(httpClient is not null); string? response = await httpClient.GetStringAsync($"api/v1/{_ControllerName}/FQA/last-quantity-and-slot-map/?waferSize=8INCH&text=Test"); Assert.IsNotNull(response); - _Logger?.LogInformation("{TestName} completed", _TestContext?.TestName); + _Logger?.LogInformation("{TestName} completed", _TestContextTestName); NonThrowTryCatch(); } diff --git a/Wafer-Counter/ApiControllers/AppSettingsController.cs b/Wafer-Counter/ApiControllers/AppSettingsController.cs index d6a4411..cf126e0 100644 --- a/Wafer-Counter/ApiControllers/AppSettingsController.cs +++ b/Wafer-Counter/ApiControllers/AppSettingsController.cs @@ -8,9 +8,9 @@ namespace OI.Metrology.Wafer.Counter.ApiControllers; public class AppSettingsController : ControllerBase, IAppSettingsController { - private readonly IAppSettingsRepository _AppSettingsRepository; + private readonly IAppSettingsRepository _AppSettingsRepository; - public AppSettingsController(IAppSettingsRepository AppSettingsRepository) => + public AppSettingsController(IAppSettingsRepository AppSettingsRepository) => _AppSettingsRepository = AppSettingsRepository; [HttpGet(nameof(IAppSettingsController.Action.App))] diff --git a/Wafer-Counter/Models/AppSettings.cs b/Wafer-Counter/Models/AppSettings.cs index 3b54fb0..9defb48 100644 --- a/Wafer-Counter/Models/AppSettings.cs +++ b/Wafer-Counter/Models/AppSettings.cs @@ -26,6 +26,52 @@ public record AppSettings(string AzureDevOpsDestinationDirectory, return result; } + private static void Verify(AppSettings appSettings) + { + if (string.IsNullOrEmpty(appSettings.Company)) + throw new Exception("Company name must have a value!"); + if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName)) + throw new Exception("Working directory name must have a value!"); + } + + public static AppSettings Get(IConfigurationRoot configurationRoot) + { + AppSettings result; + AppSettings? appSettings = configurationRoot.GetSection(nameof(AppSettings)).Get(); +#pragma warning restore IL3050, IL2026 + if (appSettings is null + || appSettings?.Company is null) + { + List paths = []; + foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers) + { + if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider) + continue; + if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider) + continue; + paths.Add(physicalFileProvider.Root); + } + throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}"); + } + result = new(appSettings.AzureDevOpsDestinationDirectory, + appSettings.BuildNumber, + appSettings.Company, + appSettings.EcCharacterizationSi, + appSettings.EcMesaFileShareCharacterizationSi, + appSettings.GitCommitSeven, + appSettings.IsDevelopment, + appSettings.IsStaging, + appSettings.MockRoot, + appSettings.MonAResource, + appSettings.MonASite, + appSettings.URLs, + appSettings.WaferCounterDestinationDirectory, + appSettings.WaferCounterTwoFileSecondsWait, + appSettings.WorkingDirectoryName); + Verify(result); + return result; + } + } [JsonSourceGenerationOptions(WriteIndented = true)] diff --git a/Wafer-Counter/Models/Binder/.editorconfig b/Wafer-Counter/Models/Binder/.editorconfig deleted file mode 100644 index 1c444cd..0000000 --- a/Wafer-Counter/Models/Binder/.editorconfig +++ /dev/null @@ -1,2 +0,0 @@ -[*.cs] -csharp_preserve_single_line_statements = true \ No newline at end of file diff --git a/Wafer-Counter/Models/Binder/AppSettings.cs b/Wafer-Counter/Models/Binder/AppSettings.cs deleted file mode 100644 index d032b9c..0000000 --- a/Wafer-Counter/Models/Binder/AppSettings.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OI.Metrology.Wafer.Counter.Models.Binder; - -public class AppSettings -{ - - public string? AzureDevOpsDestinationDirectory { get; set; } - public string? BuildNumber { get; set; } - public string? Company { get; set; } - public string? EcCharacterizationSi { get; set; } - public string? EcMesaFileShareCharacterizationSi { get; set; } - public string? GitCommitSeven { get; set; } - public bool? IsDevelopment { get; set; } - public bool? IsStaging { get; set; } - public string? MockRoot { get; set; } - public string? MonAResource { get; set; } - public string? MonASite { get; set; } - public string? URLs { get; set; } - public string? WaferCounterDestinationDirectory { get; set; } - public int? WaferCounterTwoFileSecondsWait { get; set; } - public string? WorkingDirectoryName { get; set; } - - public override string ToString() - { - string result = JsonSerializer.Serialize(this, BinderAppSettingsSourceGenerationContext.Default.AppSettings); - return result; - } - - private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings) - { - if (appSettings?.Company is null) - { - List paths = new(); - foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers) - { - if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider) - continue; - if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider) - continue; - paths.Add(physicalFileProvider.Root); - } - throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}"); - } - } - - private static Models.AppSettings Get(AppSettings? appSettings) - { - Models.AppSettings result; - if (appSettings is null) throw new NullReferenceException(nameof(appSettings)); - if (appSettings.AzureDevOpsDestinationDirectory is null) throw new NullReferenceException(nameof(AzureDevOpsDestinationDirectory)); - if (appSettings.BuildNumber is null) throw new NullReferenceException(nameof(BuildNumber)); - if (appSettings.Company is null) throw new NullReferenceException(nameof(Company)); - if (appSettings.EcCharacterizationSi is null) throw new NullReferenceException(nameof(EcCharacterizationSi)); - if (appSettings.EcMesaFileShareCharacterizationSi is null) throw new NullReferenceException(nameof(EcMesaFileShareCharacterizationSi)); - if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven)); - if (appSettings.IsDevelopment is null) throw new NullReferenceException(nameof(IsDevelopment)); - if (appSettings.IsStaging is null) throw new NullReferenceException(nameof(IsStaging)); - if (appSettings.MockRoot is null) throw new NullReferenceException(nameof(MockRoot)); - if (appSettings.MonAResource is null) throw new NullReferenceException(nameof(MonAResource)); - if (appSettings.MonASite is null) throw new NullReferenceException(nameof(MonASite)); - if (appSettings.URLs is null) throw new NullReferenceException(nameof(URLs)); - if (appSettings.WaferCounterDestinationDirectory is null) throw new NullReferenceException(nameof(WaferCounterDestinationDirectory)); - if (appSettings.WaferCounterTwoFileSecondsWait is null) throw new NullReferenceException(nameof(WaferCounterTwoFileSecondsWait)); - if (appSettings.WorkingDirectoryName is null) throw new NullReferenceException(nameof(WorkingDirectoryName)); - result = new(appSettings.AzureDevOpsDestinationDirectory, - appSettings.BuildNumber, - appSettings.Company, - appSettings.EcCharacterizationSi, - appSettings.EcMesaFileShareCharacterizationSi, - appSettings.GitCommitSeven, - appSettings.IsDevelopment.Value, - appSettings.IsStaging.Value, - appSettings.MockRoot, - appSettings.MonAResource, - appSettings.MonASite, - appSettings.URLs, - appSettings.WaferCounterDestinationDirectory, - appSettings.WaferCounterTwoFileSecondsWait.Value, - appSettings.WorkingDirectoryName); - return result; - } - - public static Models.AppSettings Get(IConfigurationRoot configurationRoot) - { - Models.AppSettings result; -#pragma warning disable IL3050, IL2026 - AppSettings? appSettings = configurationRoot.Get(); -#pragma warning restore IL3050, IL2026 - PreVerify(configurationRoot, appSettings); - result = Get(appSettings); - return result; - } - -} - -[JsonSourceGenerationOptions(WriteIndented = true)] -[JsonSerializable(typeof(AppSettings))] -internal partial class BinderAppSettingsSourceGenerationContext : JsonSerializerContext -{ -} \ No newline at end of file diff --git a/Wafer-Counter/Program.cs b/Wafer-Counter/Program.cs index 1b33cdd..19e5638 100644 --- a/Wafer-Counter/Program.cs +++ b/Wafer-Counter/Program.cs @@ -14,11 +14,7 @@ public class Program ILogger? logger = null; WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args); _ = webApplicationBuilder.Configuration.AddUserSecrets(); - AppSettings appSettings = Models.Binder.AppSettings.Get(webApplicationBuilder.Configuration); - if (string.IsNullOrEmpty(appSettings.Company)) - throw new Exception("Company name must have a value!"); - if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName)) - throw new Exception("Working directory name must have a value!"); + AppSettings appSettings = AppSettings.Get(webApplicationBuilder.Configuration); try { _ = webApplicationBuilder.Services.AddMemoryCache(); @@ -33,7 +29,7 @@ public class Program _ = webApplicationBuilder.Services.AddSingleton(); _ = webApplicationBuilder.Services.AddSingleton(); _ = webApplicationBuilder.Services.AddSingleton(); - _ = webApplicationBuilder.Services.AddSingleton>(_ => appSettingsRepository); + _ = webApplicationBuilder.Services.AddSingleton>(_ => appSettingsRepository); _ = webApplicationBuilder.Services.AddSwaggerGen(); _ = webApplicationBuilder.Services.AddSession(sessionOptions => diff --git a/Wafer-Counter/Repositories/AppSettingsRepository.cs b/Wafer-Counter/Repositories/AppSettingsRepository.cs index 41fe830..c55c4d2 100644 --- a/Wafer-Counter/Repositories/AppSettingsRepository.cs +++ b/Wafer-Counter/Repositories/AppSettingsRepository.cs @@ -3,27 +3,18 @@ using OI.Metrology.Shared.Models.Stateless; namespace OI.Metrology.Wafer.Counter.Repository; -public class AppSettingsRepository : IAppSettingsRepository +public class AppSettingsRepository : IAppSettingsRepository { private readonly AppSettings _AppSettings; - public AppSettingsRepository(AppSettings appSettings) => _AppSettings = appSettings; + public AppSettingsRepository(AppSettings appSettings) => + _AppSettings = appSettings; - internal Models.Binder.AppSettings GetAppSettings() - { - Models.Binder.AppSettings result = new() - { - BuildNumber = _AppSettings.BuildNumber, - Company = _AppSettings.Company, - GitCommitSeven = _AppSettings.GitCommitSeven, - IsDevelopment = _AppSettings.IsDevelopment, - IsStaging = _AppSettings.IsStaging, - }; - return result; - } + internal AppSettings GetAppSettings() => + _AppSettings; - Models.Binder.AppSettings IAppSettingsRepository.GetAppSettings() => GetAppSettings(); + AppSettings IAppSettingsRepository.GetAppSettings() => GetAppSettings(); internal string GetBuildNumberAndGitCommitSeven() { @@ -31,10 +22,10 @@ public class AppSettingsRepository : IAppSettingsRepository.GetBuildNumberAndGitCommitSeven() => + string IAppSettingsRepository.GetBuildNumberAndGitCommitSeven() => GetBuildNumberAndGitCommitSeven(); - void IAppSettingsRepository.VerifyConnectionStrings() => + void IAppSettingsRepository.VerifyConnectionStrings() => throw new NotImplementedException(); } \ No newline at end of file