diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD2.cs index b13cef5..00676b6 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD2.cs @@ -41,7 +41,7 @@ public class BIORAD2 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD3.cs index 2edd778..a988268 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/BIORAD3.cs @@ -41,7 +41,7 @@ public class BIORAD3 : EAFLoggingUnitTesting [ClassCleanup()] public static void ClassCleanup() { - EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); + EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); EAFLoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/MET08THFTIRQS408M.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/MET08THFTIRQS408M.cs index 7e9b9e7..4a1c7e4 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/MET08THFTIRQS408M.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.36.3/MET08THFTIRQS408M.cs @@ -41,7 +41,7 @@ public class MET08THFTIRQS408M : 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/BIORAD2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/BIORAD2.cs index 8a8efc6..ac51dc7 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/BIORAD2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/BIORAD2.cs @@ -41,7 +41,7 @@ public class BIORAD2 : 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/BIORAD3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/BIORAD3.cs index 71c7458..7b52389 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/BIORAD3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/BIORAD3.cs @@ -41,7 +41,7 @@ public class BIORAD3 : 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/MET08THFTIRQS408M.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/MET08THFTIRQS408M.cs index cc543bd..823792c 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/MET08THFTIRQS408M.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.39.0/MET08THFTIRQS408M.cs @@ -41,7 +41,7 @@ public class MET08THFTIRQS408M : 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/BIORAD2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BIORAD2.cs index 0922213..1f964d3 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BIORAD2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BIORAD2.cs @@ -41,7 +41,7 @@ public class BIORAD2 : 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/BIORAD3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BIORAD3.cs index 9c15971..c8f0b2a 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BIORAD3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/BIORAD3.cs @@ -41,7 +41,7 @@ public class BIORAD3 : 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/MET08THFTIRQS408M.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08THFTIRQS408M.cs index fe9e1ce..89f1a7c 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08THFTIRQS408M.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.43.0/MET08THFTIRQS408M.cs @@ -41,7 +41,7 @@ public class MET08THFTIRQS408M : 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.0/BIORAD2.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.0/BIORAD2.cs index 5c9824a..121b84d 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.0/BIORAD2.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.0/BIORAD2.cs @@ -43,7 +43,7 @@ public class BIORAD2 : 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.0/BIORAD3.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.0/BIORAD3.cs index 8f45b5b..1ec8d24 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.0/BIORAD3.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.0/BIORAD3.cs @@ -43,7 +43,7 @@ public class BIORAD3 : 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/MET08THFTIRQS408M.cs b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/MET08THFTIRQS408M.cs index 2e2e01e..73615d4 100644 --- a/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/MET08THFTIRQS408M.cs +++ b/Adaptation/_Tests/CreateSelfDescription/Staging/v2.47.1/MET08THFTIRQS408M.cs @@ -43,7 +43,7 @@ public class MET08THFTIRQS408M : 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/MET08THFTIRQS408M.cs b/Adaptation/_Tests/Static/MET08THFTIRQS408M.cs index b4678c0..2578a73 100644 --- a/Adaptation/_Tests/Static/MET08THFTIRQS408M.cs +++ b/Adaptation/_Tests/Static/MET08THFTIRQS408M.cs @@ -34,7 +34,7 @@ public class MET08THFTIRQS408M : LoggingUnitTesting, IDisposable [ClassCleanup()] public static void ClassCleanup() { - LoggingUnitTesting.Logger?.LogInformation("Cleanup"); + LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); LoggingUnitTesting?.Dispose(); } diff --git a/Adaptation/_Tests/Static/QS408M.cs b/Adaptation/_Tests/Static/QS408M.cs index bbb51c7..6c51036 100644 --- a/Adaptation/_Tests/Static/QS408M.cs +++ b/Adaptation/_Tests/Static/QS408M.cs @@ -34,7 +34,7 @@ public class QS408M : LoggingUnitTesting, IDisposable [ClassCleanup()] public static void ClassCleanup() { - LoggingUnitTesting.Logger?.LogInformation("Cleanup"); + LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); LoggingUnitTesting?.Dispose(); }