diff --git a/Tests/UnitTestAppSettingsController.cs b/Tests/UnitTestAppSettingsController.cs index 575fbf3..c9132eb 100644 --- a/Tests/UnitTestAppSettingsController.cs +++ b/Tests/UnitTestAppSettingsController.cs @@ -29,12 +29,20 @@ public class UnitTestAppSettingsController _ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IAppSettingsController.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -45,6 +53,7 @@ public class UnitTestAppSettingsController IAppSettingsRepository appSettingsRepository = serviceProvider.GetRequiredService>(); appSettingsRepository.VerifyConnectionStrings(); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -55,6 +64,7 @@ public class UnitTestAppSettingsController AppSettings appSettings = serviceProvider.GetRequiredService(); Assert.IsNotNull(appSettings); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -66,6 +76,7 @@ public class UnitTestAppSettingsController Server.Models.Binder.AppSettings appSettings = appSettingsRepository.GetAppSettings(); Assert.IsTrue(appSettings is not null); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -82,6 +93,7 @@ public class UnitTestAppSettingsController Assert.IsNotNull(json); Assert.IsTrue(json != "[]"); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -93,6 +105,7 @@ public class UnitTestAppSettingsController string result = appSettingsRepository.GetBuildNumberAndGitCommitSeven(); Assert.IsTrue(result is not null); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -108,6 +121,7 @@ public class UnitTestAppSettingsController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetBuildNumberAndGitCommitSeven)}.json"), json); Assert.IsNotNull(json); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/Tests/UnitTestClientSettingsController.cs b/Tests/UnitTestClientSettingsController.cs index c4b14ab..5d0e835 100644 --- a/Tests/UnitTestClientSettingsController.cs +++ b/Tests/UnitTestClientSettingsController.cs @@ -54,8 +54,8 @@ public class UnitTestClientSettingsController { HttpClient httpClient = _WebApplicationFactory.CreateClient(); _Logger.Information("Starting Web Application"); - string actionName = nameof(IClientSettingsController.Action.Client); #if DEBUG + string actionName = nameof(IClientSettingsController.Action.Client); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}"); Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode); Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString()); diff --git a/Tests/UnitTestExportController.cs b/Tests/UnitTestExportController.cs index 4a5613f..8e296e5 100644 --- a/Tests/UnitTestExportController.cs +++ b/Tests/UnitTestExportController.cs @@ -29,12 +29,20 @@ public class UnitTestExportController _ControllerName = nameof(Server.ApiControllers.ExportController)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IExportController.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } private static HeaderCommon GetHeaderCommon() => @@ -52,6 +60,7 @@ public class UnitTestExportController string result = exportRepository.GetExport(GetHeaderCommon()); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -63,6 +72,7 @@ public class UnitTestExportController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -73,6 +83,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -84,6 +95,7 @@ public class UnitTestExportController Result result = exportRepository.GetHeaders(GetHeaderCommon()); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -96,6 +108,7 @@ public class UnitTestExportController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -106,6 +119,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -117,6 +131,7 @@ public class UnitTestExportController Result result = exportRepository.GetLogistics(GetHeaderCommon()); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -129,6 +144,7 @@ public class UnitTestExportController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -139,6 +155,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -150,6 +167,7 @@ public class UnitTestExportController string result = exportRepository.GetProcessDataStandardFormat(GetHeaderCommon()); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -161,6 +179,7 @@ public class UnitTestExportController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } [TestMethod] @@ -171,6 +190,7 @@ public class UnitTestExportController HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent()); Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/Tests/UnitTestInfinityQSController.cs b/Tests/UnitTestInfinityQSController.cs index 2b3fb8b..f4c5c15 100644 --- a/Tests/UnitTestInfinityQSController.cs +++ b/Tests/UnitTestInfinityQSController.cs @@ -28,15 +28,23 @@ public class UnitTestInfinityQSController _ControllerName = nameof(Server.ApiControllers.InfinityQSController)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IInfinityQSController.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -48,9 +56,10 @@ public class UnitTestInfinityQSController string result = infinityQSRepository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -62,9 +71,10 @@ public class UnitTestInfinityQSController File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -82,9 +92,10 @@ public class UnitTestInfinityQSController Assert.IsNotNull(result?.Results[0].TD_NAME); Assert.IsNotNull(result?.Results[0].TD_TEST); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -98,9 +109,10 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -115,9 +127,10 @@ public class UnitTestInfinityQSController Assert.IsNotNull(result?.Results[0].SD_SGRP); Assert.IsNotNull(result?.Results[0].SD_TSNO); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -131,9 +144,10 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -145,9 +159,10 @@ public class UnitTestInfinityQSController Result result = infinityQSRepository.GetEvents("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -160,9 +175,10 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -174,9 +190,10 @@ public class UnitTestInfinityQSController Result result = infinityQSRepository.GetHeader("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -189,6 +206,7 @@ public class UnitTestInfinityQSController Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/Tests/UnitTestInfinityQSV2Controller.cs b/Tests/UnitTestInfinityQSV2Controller.cs index 60bc595..c83deab 100644 --- a/Tests/UnitTestInfinityQSV2Controller.cs +++ b/Tests/UnitTestInfinityQSV2Controller.cs @@ -28,17 +28,22 @@ public class UnitTestInfinityQSV2Controller _ControllerName = nameof(Server.ApiControllers.InfinityQSV2Controller)[..^10]; } + private static void NonThrowTryCatch() + { + try + { throw new Exception(); } + catch (Exception) { } + } + [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IInfinityQSV2Controller.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true - [Ignore] -#endif [TestMethod] public void GetCommandText() { @@ -48,9 +53,10 @@ public class UnitTestInfinityQSV2Controller string result = infinityQSV2Repository.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", ""); Assert.IsNotNull(result); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -62,9 +68,10 @@ public class UnitTestInfinityQSV2Controller File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json); Assert.IsNotNull(json); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -82,9 +89,10 @@ public class UnitTestInfinityQSV2Controller Assert.IsNotNull(result?.Results[0].VariableNumber); Assert.IsNotNull(result?.Results[0].SubGroupDateTime); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -98,9 +106,10 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -115,9 +124,10 @@ public class UnitTestInfinityQSV2Controller Assert.IsNotNull(result?.Results[0].SubGroupId); Assert.IsNotNull(result?.Results[0].SiteNumber); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -131,9 +141,10 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -145,9 +156,10 @@ public class UnitTestInfinityQSV2Controller Result result = infinityQSV2Repository.GetEvents("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -160,9 +172,10 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -174,9 +187,10 @@ public class UnitTestInfinityQSV2Controller Result result = infinityQSV2Repository.GetHeader("1677273357"); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } -#if true +#if !DEBUG [Ignore] #endif [TestMethod] @@ -189,6 +203,7 @@ public class UnitTestInfinityQSV2Controller Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); _Logger.Information($"{_TestContext?.TestName} completed"); + NonThrowTryCatch(); } } \ No newline at end of file diff --git a/azure-pipelines-server-development.yml b/azure-pipelines-server-development.yml index 0a10f87..4d96c91 100644 --- a/azure-pipelines-server-development.yml +++ b/azure-pipelines-server-development.yml @@ -132,6 +132,14 @@ steps: testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: PublishTestResults@2 + displayName: "Publish Test Results **/coverage.cobertura.xml" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/coverage.cobertura.xml" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 displayName: "Create work item" inputs: diff --git a/azure-pipelines-server.yml b/azure-pipelines-server.yml index 5ef60c1..cd5fbb1 100644 --- a/azure-pipelines-server.yml +++ b/azure-pipelines-server.yml @@ -110,6 +110,14 @@ steps: testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: PublishTestResults@2 + displayName: "Publish Test Results **/coverage.cobertura.xml" + inputs: + testResultsFormat: VSTest + testResultsFiles: "**/coverage.cobertura.xml" + testRunTitle: "$(GitCommitSeven)-$(Build.BuildId)-$(CoreVersion)-$(Configuration)-$(Build.Repository.Name)" + searchFolder: "$(System.DefaultWorkingDirectory)/.vscode" + - task: mspremier.CreateWorkItem.CreateWorkItem-task.CreateWorkItem@1 displayName: "Create work item" inputs: