nuget ^
This commit is contained in:
		| @ -40,7 +40,7 @@ public class EC : EAFLoggingUnitTesting | ||||
|     [ClassCleanup()] | ||||
|     public static void ClassCleanup() | ||||
|     { | ||||
|         EAFLoggingUnitTesting.Logger?.LogInformation("Cleanup"); | ||||
|         EAFLoggingUnitTesting?.Logger?.LogInformation("Cleanup"); | ||||
|         EAFLoggingUnitTesting?.Dispose(); | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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<TestCategoryAttribute>(); | ||||
|                 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<TestCategoryAttribute>(); | ||||
|                     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; | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -34,7 +34,7 @@ public class EC : LoggingUnitTesting, IDisposable | ||||
|     [ClassCleanup()] | ||||
|     public static void ClassCleanup() | ||||
|     { | ||||
|         LoggingUnitTesting.Logger?.LogInformation("Cleanup"); | ||||
|         LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); | ||||
|         LoggingUnitTesting?.Dispose(); | ||||
|     } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user