Inititial Commit

This commit is contained in:
2023-04-22 21:42:57 -07:00
parent 660b89c129
commit c7995ffd4f
58 changed files with 1312 additions and 905 deletions

View File

@ -29,41 +29,46 @@ 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);
}
if (_IsEnvironment is null)
_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++)
{
@ -74,8 +79,6 @@ public class UnitTesting
break;
result = Path.GetDirectoryName(result);
}
if (string.IsNullOrEmpty(result) || checkFiles is null || !checkFiles.Any())
throw new Exception(result);
return result;
}