From d009b8d8f7fe1189a4976e056e57b20f96e3f725 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Mon, 13 Feb 2023 07:10:00 -0700 Subject: [PATCH] Change int dotnet test --- .../Staging/v2.39.0/HGCV1.cs | 2 +- .../Staging/v2.39.0/HGCV2.cs | 2 +- .../Staging/v2.39.0/HGCV3.cs | 2 +- .../Staging/v2.39.0/MET08RESIHGCV.cs | 2 +- .../Staging/v2.43.0/HGCV1.cs | 2 +- .../Staging/v2.43.0/HGCV2.cs | 2 +- .../Staging/v2.43.0/HGCV3.cs | 2 +- .../Staging/v2.43.0/MET08RESIHGCV.cs | 2 +- .../Staging/v2.43.4/HGCV1.cs | 2 +- .../Staging/v2.43.4/HGCV2.cs | 2 +- .../Staging/v2.43.4/HGCV3.cs | 2 +- .../Staging/v2.43.4/MET08RESIHGCV.cs | 2 +- .../Staging/v2.47.1/HGCV1.cs | 2 +- .../Staging/v2.47.1/HGCV2.cs | 2 +- .../Staging/v2.47.1/HGCV3.cs | 2 +- .../Staging/v2.47.1/MET08RESIHGCV.cs | 2 +- .../_Tests/Shared/LoggingUnitTesting.cs | 2 +- Adaptation/_Tests/Shared/UnitTesting.cs | 51 ++++++++++--------- Adaptation/_Tests/Static/MET08RESIHGCV.cs | 2 +- Adaptation/_Tests/Static/pcl.cs | 2 +- 20 files changed, 46 insertions(+), 43 deletions(-) diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV1.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV1.cs index 0c56e2a..3ce95c7 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV1.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV1.cs @@ -41,7 +41,7 @@ public class HGCV1 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV2.cs index fe511f0..1ada1b1 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV2.cs @@ -41,7 +41,7 @@ public class HGCV2 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV3.cs index 5b6b8c1..97c080e 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/HGCV3.cs @@ -41,7 +41,7 @@ public class HGCV3 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/MET08RESIHGCV.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/MET08RESIHGCV.cs index 9c05a49..f2cdeee 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/MET08RESIHGCV.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/MET08RESIHGCV.cs @@ -41,7 +41,7 @@ public class MET08RESIHGCV : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV1.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV1.cs index e9676ad..282176c 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV1.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV1.cs @@ -41,7 +41,7 @@ public class HGCV1 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV2.cs index 85565bf..193ced7 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV2.cs @@ -41,7 +41,7 @@ public class HGCV2 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV3.cs index aea6261..93d04d0 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/HGCV3.cs @@ -41,7 +41,7 @@ public class HGCV3 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08RESIHGCV.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08RESIHGCV.cs index fb4bce3..f5a4c15 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08RESIHGCV.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08RESIHGCV.cs @@ -41,7 +41,7 @@ public class MET08RESIHGCV : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV1.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV1.cs index b49dc74..0577ca7 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV1.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV1.cs @@ -43,7 +43,7 @@ public class HGCV1 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV2.cs index 795316e..7d70f02 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV2.cs @@ -43,7 +43,7 @@ public class HGCV2 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV3.cs index 0c2435c..f93a365 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/HGCV3.cs @@ -43,7 +43,7 @@ public class HGCV3 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/MET08RESIHGCV.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/MET08RESIHGCV.cs index 452f44e..e18041b 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/MET08RESIHGCV.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.4/MET08RESIHGCV.cs @@ -43,7 +43,7 @@ public class MET08RESIHGCV : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV1.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV1.cs index f9541b9..9ba1a05 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV1.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV1.cs @@ -43,7 +43,7 @@ public class HGCV1 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV2.cs index c18ca2e..d18afa4 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV2.cs @@ -43,7 +43,7 @@ public class HGCV2 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV3.cs index 7c5da3a..e44514f 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/HGCV3.cs @@ -43,7 +43,7 @@ public class HGCV3 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/MET08RESIHGCV.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/MET08RESIHGCV.cs index 363b369..b31fe54 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/MET08RESIHGCV.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/MET08RESIHGCV.cs @@ -43,7 +43,7 @@ public class MET08RESIHGCV : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/Shared/LoggingUnitTesting.cs b/Adaptation/_Tests/Shared/LoggingUnitTesting.cs index f5c6a40..9628850 100644 --- a/Adaptation/_Tests/Shared/LoggingUnitTesting.cs +++ b/Adaptation/_Tests/Shared/LoggingUnitTesting.cs @@ -26,7 +26,7 @@ public class LoggingUnitTesting : UnitTesting, IDisposable base(testContext, declaringType) { _LoggerFactory = new LoggerFactory(); - if (testContext is null || declaringType is null) + if (testContext is null || declaringType is null || _IsEnvironment is null) { _ConfigurationRoot = null; _DefaultLogLevel = null; diff --git a/Adaptation/_Tests/Shared/UnitTesting.cs b/Adaptation/_Tests/Shared/UnitTesting.cs index 38cf36f..1833834 100644 --- a/Adaptation/_Tests/Shared/UnitTesting.cs +++ b/Adaptation/_Tests/Shared/UnitTesting.cs @@ -29,40 +29,45 @@ public class UnitTesting { string waitFor = "\"WaitFor\":"; string projectDirectory = GetProjectDirectory(testContext); - _TestContextPropertiesAsJson = JsonSerializer.Serialize(testContext.Properties, new JsonSerializerOptions { WriteIndented = true }); - _HasWaitForProperty = _TestContextPropertiesAsJson.Contains(waitFor); - string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode"); - if (!Directory.Exists(vsCodeDirectory)) - _ = Directory.CreateDirectory(vsCodeDirectory); - string launchText = GetLaunchText(); - File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText); - if (_HasWaitForProperty) + if (string.IsNullOrEmpty(projectDirectory)) + _IsEnvironment = null; + else { - for (int i = 0; i < int.MaxValue; i++) + _TestContextPropertiesAsJson = JsonSerializer.Serialize(testContext.Properties, new JsonSerializerOptions { WriteIndented = true }); + _HasWaitForProperty = _TestContextPropertiesAsJson.Contains(waitFor); + string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode"); + if (!Directory.Exists(vsCodeDirectory)) + _ = Directory.CreateDirectory(vsCodeDirectory); + string launchText = GetLaunchText(); + File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText); + if (_HasWaitForProperty) { - if (!_TestContextPropertiesAsJson.Contains($"{waitFor} \"Debugger.IsAttached\"") || Debugger.IsAttached) - break; - Thread.Sleep(500); + for (int i = 0; i < int.MaxValue; i++) + { + if (!_TestContextPropertiesAsJson.Contains($"{waitFor} \"Debugger.IsAttached\"") || Debugger.IsAttached) + break; + Thread.Sleep(500); + } } - } - MethodBase methodBase = declaringType.GetMethod(testContext.TestName); - if (methodBase is not null) - { - TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute(); - if (testCategoryAttribute is not null) + MethodBase methodBase = declaringType.GetMethod(testContext.TestName); + if (methodBase is not null) { - foreach (string testCategory in testCategoryAttribute.TestCategories) - _IsEnvironment = new IsEnvironment(testCategory); + TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute(); + if (testCategoryAttribute is not null) + { + foreach (string testCategory in testCategoryAttribute.TestCategories) + _IsEnvironment = new IsEnvironment(testCategory); + } } + _IsEnvironment ??= new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached); } - _IsEnvironment ??= new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached); } } internal static string GetProjectDirectory(TestContext testContext) { string result; - string[] checkFiles = null; + string[] checkFiles; result = Path.GetDirectoryName(testContext.DeploymentDirectory); for (int i = 0; i < int.MaxValue; i++) { @@ -73,8 +78,6 @@ public class UnitTesting break; result = Path.GetDirectoryName(result); } - if (string.IsNullOrEmpty(result) || checkFiles is null || !checkFiles.Any()) - throw new Exception(result); return result; } diff --git a/Adaptation/_Tests/Static/MET08RESIHGCV.cs b/Adaptation/_Tests/Static/MET08RESIHGCV.cs index 0167e2d..91f327d 100644 --- a/Adaptation/_Tests/Static/MET08RESIHGCV.cs +++ b/Adaptation/_Tests/Static/MET08RESIHGCV.cs @@ -34,7 +34,7 @@ public class MET08RESIHGCV : LoggingUnitTesting, IDisposable [ClassCleanup()] public static void ClassCleanup() { - LoggingUnitTesting.Logger?.LogInformation("Cleanup"); + LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); LoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/Static/pcl.cs b/Adaptation/_Tests/Static/pcl.cs index 2638b0a..5a8b663 100644 --- a/Adaptation/_Tests/Static/pcl.cs +++ b/Adaptation/_Tests/Static/pcl.cs @@ -34,7 +34,7 @@ public class PCL : LoggingUnitTesting, IDisposable [ClassCleanup()] public static void ClassCleanup() { - LoggingUnitTesting.Logger?.LogInformation("Cleanup"); + LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); LoggingUnitTesting?.Dispose(); }