Removed old GetRectangle
RectangleIntersectMinimums AddUserSecrets
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
@ -6,6 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<UserSecretsId>e8c3d25d-9715-4b35-9010-1cdc74840190</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VSTestLogger>trx</VSTestLogger>
|
||||
|
@ -39,7 +39,8 @@ public partial class UnitTestCalculations
|
||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||
.AddUserSecrets<UnitTestCalculations>();
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
@ -93,6 +94,7 @@ public partial class UnitTestCalculations
|
||||
throw new NullReferenceException(nameof(age));
|
||||
Assert.IsNotNull(age);
|
||||
Assert.IsTrue(age.Value > 42.6092);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -114,6 +116,7 @@ public partial class UnitTestCalculations
|
||||
Assert.IsTrue($"({l}{d.ToString("0.00")[1..]})" == "(637967784888423594.62)");
|
||||
d = 0.45;
|
||||
Assert.IsTrue($"({l}{d.ToString("0.00")[1..]})" == "(637967784888423594.45)");
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -123,6 +126,7 @@ public partial class UnitTestCalculations
|
||||
Assert.IsTrue(successful == "_ Manual Copy Successful");
|
||||
string verify = $"_ {nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Verify";
|
||||
Assert.IsTrue(verify == "_ Manual Copy Verify");
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -154,6 +158,7 @@ public partial class UnitTestCalculations
|
||||
// "7680x4320 - Hog - Large"
|
||||
// [8] [string]:
|
||||
// "()"
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -170,6 +175,7 @@ public partial class UnitTestCalculations
|
||||
Location location = new(bottom, confidence, left, right, top);
|
||||
_ = new Location(confidence, height, location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, 1);
|
||||
_ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -186,7 +192,7 @@ public partial class UnitTestCalculations
|
||||
width = 100;
|
||||
height = 100;
|
||||
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, bottom, height, left, right, top, width);
|
||||
Assert.IsTrue(areaPermyriad == 1000);
|
||||
Assert.IsTrue(areaPermyriad == 10000);
|
||||
left = 0;
|
||||
right = 50;
|
||||
top = 0;
|
||||
@ -195,7 +201,7 @@ public partial class UnitTestCalculations
|
||||
height = 100;
|
||||
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, height, location, width);
|
||||
Assert.IsTrue(areaPermyriad == 250);
|
||||
Assert.IsTrue(areaPermyriad == 2500);
|
||||
left = 0;
|
||||
right = 25;
|
||||
top = 0;
|
||||
@ -205,30 +211,8 @@ public partial class UnitTestCalculations
|
||||
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||
OutputResolution outputResolution = new(height, 0, width);
|
||||
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, location, outputResolution);
|
||||
Assert.IsTrue(areaPermyriad == 62);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestNormalizedRectangle()
|
||||
{
|
||||
int? x, y;
|
||||
int normalizedRectangle;
|
||||
int bottom, height, left, right, top, width;
|
||||
string normalizedRectanglePadded;
|
||||
width = 2048;
|
||||
height = 1365;
|
||||
normalizedRectanglePadded = "617214031";
|
||||
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedRectanglePadded);
|
||||
if (x is null || y is null)
|
||||
throw new Exception();
|
||||
Assert.IsTrue(x.Value == 1264);
|
||||
Assert.IsTrue(y.Value == 192);
|
||||
left = x.Value;
|
||||
right = x.Value + 125;
|
||||
top = y.Value;
|
||||
bottom = y.Value + 100;
|
||||
normalizedRectangle = ILocation.GetNormalizedRectangle(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, right, top, width);
|
||||
Assert.IsTrue(normalizedRectangle == 461140607);
|
||||
Assert.IsTrue(areaPermyriad == 625);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -241,6 +225,7 @@ public partial class UnitTestCalculations
|
||||
y2 = 10f;
|
||||
double distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
|
||||
Assert.IsTrue(distance == 1.4142135623730951);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -266,6 +251,7 @@ public partial class UnitTestCalculations
|
||||
value = 1.6f;
|
||||
check = ILocation.GetConfidencePercent(faceConfidencePercent, new float[] { minimum, target, maximum }, value);
|
||||
Assert.IsTrue(check == 200);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -36,7 +36,9 @@ public class UnitTestExample
|
||||
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||
.AddUserSecrets<UnitTestExample>();
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
|
@ -38,7 +38,8 @@ public partial class UnitTestHardCoded
|
||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||
.AddUserSecrets<UnitTestHardCoded>();
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
@ -83,10 +84,13 @@ public partial class UnitTestHardCoded
|
||||
[TestMethod]
|
||||
public void TestMethodDel()
|
||||
{
|
||||
string source = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
||||
for (int i = 1; i < 11; i++)
|
||||
_ = IPath.DeleteEmptyDirectories(source);
|
||||
Assert.IsTrue(true);
|
||||
string directory = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
for (int i = 1; i < 11; i++)
|
||||
_ = IPath.DeleteEmptyDirectories(directory);
|
||||
Assert.IsTrue(true);
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
@ -114,50 +118,16 @@ public partial class UnitTestHardCoded
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodDamn()
|
||||
{
|
||||
// string name;
|
||||
// string[] directories;
|
||||
// string? directoryName;
|
||||
// string checkDirectory;
|
||||
// string sourceDirectory = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()";
|
||||
// directories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
// foreach (string directory in directories)
|
||||
// {
|
||||
// directoryName = Path.GetDirectoryName(directory);
|
||||
// if (directoryName is null)
|
||||
// continue;
|
||||
// name = Path.GetFileName(directory);
|
||||
// if (name.Length is 1 or 20)
|
||||
// continue;
|
||||
// checkDirectory = Path.Combine(directoryName, "b", name);
|
||||
// Directory.Move(directory, checkDirectory);
|
||||
// }
|
||||
// directories = Directory.GetDirectories(Path.Combine(sourceDirectory, "b"), "*", SearchOption.TopDirectoryOnly);
|
||||
// foreach (string directory in directories)
|
||||
// {
|
||||
// directoryName = Path.GetDirectoryName(directory);
|
||||
// if (directoryName is null)
|
||||
// continue;
|
||||
// name = Path.GetFileName(directory);
|
||||
// if (name.Length is 1 or 20)
|
||||
// continue;
|
||||
// checkDirectory = Path.Combine(directoryName, $"{name[..^4]})");
|
||||
// if (Directory.Exists(checkDirectory))
|
||||
// continue;
|
||||
// Directory.Move(directory, checkDirectory);
|
||||
// }
|
||||
// Assert.IsTrue(true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodDel2()
|
||||
{
|
||||
string source = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
||||
for (int i = 1; i < 11; i++)
|
||||
_ = IPath.DeleteEmptyDirectories(source);
|
||||
Assert.IsTrue(true);
|
||||
string directory = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
for (int i = 1; i < 11; i++)
|
||||
_ = IPath.DeleteEmptyDirectories(directory);
|
||||
Assert.IsTrue(true);
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
@ -230,87 +200,100 @@ public partial class UnitTestHardCoded
|
||||
[TestMethod]
|
||||
public void TestMethodRenameAbandoned()
|
||||
{
|
||||
string checkFile;
|
||||
string source = @"D:\1) Images A\Images-1e85c0ba-Results\A2) People\1e85c0ba\{}\!\Abandoned";
|
||||
string[] files = Directory.GetFiles(source, "*.abd", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
string directory = @"D:\1) Images A\Images-1e85c0ba-Results\A2) People\1e85c0ba\{}\!\Abandoned";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
checkFile = file[..^4];
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
string checkFile;
|
||||
string[] files = Directory.GetFiles(directory, "*.abd", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
checkFile = file[..^4];
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
Assert.IsTrue(true);
|
||||
}
|
||||
Assert.IsTrue(true);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodRenameDelete()
|
||||
{
|
||||
string checkFile;
|
||||
string source = @"D:\1) Images A\Images-1e85c0ba-Results\A) Property\1e85c0ba\{}";
|
||||
string[] files = Directory.GetFiles(source, "*.del", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
string directory = @"D:\1) Images A\Images-1e85c0ba-Results\A) Property\1e85c0ba\{}";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
checkFile = file[..^4];
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
string checkFile;
|
||||
string[] files = Directory.GetFiles(directory, "*.del", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
checkFile = file[..^4];
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
Assert.IsTrue(true);
|
||||
}
|
||||
Assert.IsTrue(true);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodRenameOld()
|
||||
{
|
||||
string checkFile;
|
||||
string source = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba-Results\E) Distance\1e85c0ba\()";
|
||||
string[] files = Directory.GetFiles(source, "*.old", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
string directory = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba-Results\E) Distance\1e85c0ba\()";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
checkFile = file[..^4];
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
string checkFile;
|
||||
string[] files = Directory.GetFiles(directory, "*.old", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
checkFile = file[..^4];
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
}
|
||||
Assert.IsTrue(true);
|
||||
}
|
||||
Assert.IsTrue(true);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodAncestryGenealogicalDataCommunication()
|
||||
{
|
||||
List<string> mappedLines;
|
||||
Dictionary<string, List<string>> individuals;
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||
List<(bool, string)> genealogicalDataCommunicationFiles = new()
|
||||
string directory = "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
new(false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Roberts/Roberts Family Tree.ged"),
|
||||
new(false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Phares/Phares Jr Family Tree.ged"),
|
||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583.ged"),
|
||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160728606500015/638160728606500015.ged"),
|
||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877.ged"),
|
||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885.ged"),
|
||||
new(false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Porterfield/Porterfield Family Tree.ged"),
|
||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583-Export.ged"),
|
||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877-Export.ged"),
|
||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885-Export.ged"),
|
||||
};
|
||||
foreach ((bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||
{
|
||||
(_, individuals, _) = IGenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
foreach (KeyValuePair<string, List<string>> keyValuePair in individuals)
|
||||
List<string> mappedLines;
|
||||
Dictionary<string, List<string>> individuals;
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||
List<(bool, string)> genealogicalDataCommunicationFiles = new()
|
||||
{
|
||||
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
|
||||
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
|
||||
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(genealogicalDataCommunicationLines);
|
||||
Assert.IsNotNull(genealogicalDataCommunication.Name);
|
||||
new(false, Path.Combine(directory, "Ancestry-Roberts/Roberts Family Tree.ged")),
|
||||
new(false, Path.Combine(directory, "Ancestry-Phares/Phares Jr Family Tree.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160708345114583/638160708345114583.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160728606500015/638160728606500015.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160738845419877/638160738845419877.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160743318283885/638160743318283885.ged")),
|
||||
new(false, Path.Combine(directory, "Ancestry-Porterfield/Porterfield Family Tree.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160708345114583/638160708345114583-Export.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160738845419877/638160738845419877-Export.ged")),
|
||||
new(true, Path.Combine(directory, "Code-638160743318283885/638160743318283885-Export.ged")),
|
||||
};
|
||||
foreach ((bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||
{
|
||||
(_, individuals, _) = IGenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
foreach (KeyValuePair<string, List<string>> keyValuePair in individuals)
|
||||
{
|
||||
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
|
||||
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
|
||||
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(genealogicalDataCommunicationLines);
|
||||
Assert.IsNotNull(genealogicalDataCommunication.Name);
|
||||
}
|
||||
mappedLines = IGenealogicalDataCommunication.GetMappedLines(genealogicalDataCommunicationFile, requireNickName);
|
||||
if (IPath.WriteAllText($"{genealogicalDataCommunicationFile}.cln", string.Join(Environment.NewLine, mappedLines), updateDateWhenMatches: false, compareBeforeWrite: true))
|
||||
continue;
|
||||
}
|
||||
mappedLines = IGenealogicalDataCommunication.GetMappedLines(genealogicalDataCommunicationFile, requireNickName);
|
||||
if (IPath.WriteAllText($"{genealogicalDataCommunicationFile}.cln", string.Join(Environment.NewLine, mappedLines), updateDateWhenMatches: false, compareBeforeWrite: true))
|
||||
continue;
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
@ -318,71 +301,74 @@ public partial class UnitTestHardCoded
|
||||
[TestMethod]
|
||||
public void TestMethodAncestryGenealogicalDataCommunicationCleanToExport()
|
||||
{
|
||||
int age;
|
||||
long personKey;
|
||||
string ageGroup;
|
||||
string fileName;
|
||||
string? directory;
|
||||
bool first = true;
|
||||
PersonName? personName;
|
||||
string personKeyFormatted;
|
||||
bool isDefaultName = false;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
Dictionary<string, List<string>> individuals;
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||
string saveDirectory = $"D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-{dateTime.Ticks}";
|
||||
List<(bool, bool, string)> genealogicalDataCommunicationFiles = new()
|
||||
string saveDirectory = "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])";
|
||||
if (Directory.Exists(Path.GetPathRoot(saveDirectory)) && Directory.Exists(saveDirectory))
|
||||
{
|
||||
new(false, false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Roberts/Roberts Family Tree.ged.cln"),
|
||||
new(false, false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Phares/Phares Jr Family Tree.ged.cln"),
|
||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583.ged.cln"),
|
||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160728606500015/638160728606500015.ged.cln"),
|
||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877.ged.cln"),
|
||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885.ged.cln"),
|
||||
new(false, false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Porterfield/Porterfield Family Tree.ged.cln"),
|
||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583-Export.ged.cln"),
|
||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877-Export.ged.cln"),
|
||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885-Export.ged.cln"),
|
||||
};
|
||||
foreach ((bool verify, bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||
{
|
||||
fileName = Path.GetFileNameWithoutExtension(genealogicalDataCommunicationFile).Split(' ')[0];
|
||||
(_, individuals, _) = IGenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
foreach (KeyValuePair<string, List<string>> keyValuePair in individuals)
|
||||
int age;
|
||||
long personKey;
|
||||
string ageGroup;
|
||||
string fileName;
|
||||
string? directory;
|
||||
bool first = true;
|
||||
PersonName? personName;
|
||||
string personKeyFormatted;
|
||||
bool isDefaultName = false;
|
||||
Dictionary<string, List<string>> individuals;
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||
List<(bool, bool, string)> genealogicalDataCommunicationFiles = new()
|
||||
{
|
||||
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
|
||||
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
|
||||
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(genealogicalDataCommunicationLines);
|
||||
Assert.IsNotNull(genealogicalDataCommunication.Name);
|
||||
if (genealogicalDataCommunication.Birth is null)
|
||||
continue;
|
||||
personName = IPersonName.GetPersonName(genealogicalDataCommunication);
|
||||
if (personName is null)
|
||||
continue;
|
||||
personKey = genealogicalDataCommunication.Birth.Value.Ticks;
|
||||
(age, _) = IAge.GetAge(dateTime.Ticks, personKey);
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_PropertyConfiguration.PersonBirthdayFormat, personKey);
|
||||
if (age < 25)
|
||||
ageGroup = "1) Less-25";
|
||||
else if (age < 50)
|
||||
ageGroup = "2) Less-50";
|
||||
else if (age < 100)
|
||||
ageGroup = "3) Less-100";
|
||||
else if (age < 200)
|
||||
ageGroup = "4) Less-200";
|
||||
else
|
||||
ageGroup = "5) Else";
|
||||
directory = Path.Combine(saveDirectory, fileName, ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, keyValuePair.Value, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||
new(false, false, Path.Combine(saveDirectory, "Ancestry-Roberts/Roberts Family Tree.ged.cln")),
|
||||
new(false, false, Path.Combine(saveDirectory, "Ancestry-Phares/Phares Jr Family Tree.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160708345114583/638160708345114583.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160728606500015/638160728606500015.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160738845419877/638160738845419877.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160743318283885/638160743318283885.ged.cln")),
|
||||
new(false, false, Path.Combine(saveDirectory, "Ancestry-Porterfield/Porterfield Family Tree.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160708345114583/638160708345114583-Export.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160738845419877/638160738845419877-Export.ged.cln")),
|
||||
new(true, true, Path.Combine(saveDirectory, "Code-638160743318283885/638160743318283885-Export.ged.cln")),
|
||||
};
|
||||
foreach ((bool verify, bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||
{
|
||||
fileName = Path.GetFileNameWithoutExtension(genealogicalDataCommunicationFile).Split(' ')[0];
|
||||
(_, individuals, _) = IGenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
|
||||
foreach (KeyValuePair<string, List<string>> keyValuePair in individuals)
|
||||
{
|
||||
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
|
||||
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
|
||||
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(genealogicalDataCommunicationLines);
|
||||
Assert.IsNotNull(genealogicalDataCommunication.Name);
|
||||
if (genealogicalDataCommunication.Birth is null)
|
||||
continue;
|
||||
personName = IPersonName.GetPersonName(genealogicalDataCommunication);
|
||||
if (personName is null)
|
||||
continue;
|
||||
personKey = genealogicalDataCommunication.Birth.Value.Ticks;
|
||||
(age, _) = IAge.GetAge(dateTime.Ticks, personKey);
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_PropertyConfiguration.PersonBirthdayFormat, personKey);
|
||||
if (age < 25)
|
||||
ageGroup = "1) Less-25";
|
||||
else if (age < 50)
|
||||
ageGroup = "2) Less-50";
|
||||
else if (age < 100)
|
||||
ageGroup = "3) Less-100";
|
||||
else if (age < 200)
|
||||
ageGroup = "4) Less-200";
|
||||
else
|
||||
ageGroup = "5) Else";
|
||||
directory = Path.Combine(saveDirectory, fileName, ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, keyValuePair.Value, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||
}
|
||||
}
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
private static string[] GetFamily() => new string[]{
|
||||
private static string[] GetFamily() => new string[] {
|
||||
"UBertha Scott (Barry Scott) 10/2/1900-8/19/1993",
|
||||
"MEarl Daniel Herman 1/5/1918-10/19/1962",
|
||||
"FGlendola Koch 8/10/1919-5/16/1910",
|
||||
@ -592,7 +578,7 @@ public partial class UnitTestHardCoded
|
||||
"MDevan Hazen 8/14/1999",
|
||||
"MEthan Hazen 8/14/1999",
|
||||
"FApril Hill 6/9/1980",
|
||||
"MRandall Hill 1/16/1978", // https://www.facebook.com/randall.d.hill/about_contact_and_basic_info // https://www.facebook.com/photo.php?fbid=10154576010477639&set=pb.530957638.-2207520000.&type=3 // https://scontent-lax3-1.xx.fbcdn.net/v/t1.18169-9/16265790_10154576010477639_102119672782426718_n.jpg?_nc_cat=102&ccb=1-7&_nc_sid=174925&_nc_ohc=cWEECl9DMhoAX_qlUB-&_nc_ht=scontent-lax3-1.xx&oh=00_AfC4PZ-tytVowtRSu1AJtkxRkQb0_j0WSDk4MKquqs0img&oe=64531181
|
||||
"MRandall Hill 1/16/1978", // https://www.facebook.com/randall.directory.hill/about_contact_and_basic_info // https://www.facebook.com/photo.php?fbid=10154576010477639&set=pb.530957638.-2207520000.&type=3 // https://scontent-lax3-1.xx.fbcdn.net/v/t1.18169-9/16265790_10154576010477639_102119672782426718_n.jpg?_nc_cat=102&ccb=1-7&_nc_sid=174925&_nc_ohc=cWEECl9DMhoAX_qlUB-&_nc_ht=scontent-lax3-1.xx&oh=00_AfC4PZ-tytVowtRSu1AJtkxRkQb0_j0WSDk4MKquqs0img&oe=64531181
|
||||
"FBrenda Olson 8/27/1958", // https://www.facebook.com/barbara.olson.96/about_contact_and_basic_info
|
||||
"MChris Olson 11/13/1951",
|
||||
"FShilo Zeches 4/9/1980",
|
||||
@ -675,66 +661,70 @@ public partial class UnitTestHardCoded
|
||||
[TestMethod]
|
||||
public void TestMethodFamily()
|
||||
{
|
||||
int age;
|
||||
string name;
|
||||
long personKey;
|
||||
DateTime? death;
|
||||
string ageGroup;
|
||||
bool first = true;
|
||||
string? directory;
|
||||
bool verify = false;
|
||||
string[] dateSegments;
|
||||
DateTime parseDateTime;
|
||||
PersonName? personName;
|
||||
string[] spaceSegments;
|
||||
string personKeyFormatted;
|
||||
bool isDefaultName = false;
|
||||
PersonBirthday personBirthday;
|
||||
string[] family = GetFamily();
|
||||
DateTime dateTime = DateTime.Now;
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
string saveDirectory = $"D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Norman-{dateTime.Ticks}";
|
||||
foreach (string familyMember in family)
|
||||
if (Directory.Exists(Path.GetPathRoot(saveDirectory)) && Directory.Exists(saveDirectory))
|
||||
{
|
||||
spaceSegments = familyMember[1..].Split(' ');
|
||||
dateSegments = spaceSegments[^1].Split('-');
|
||||
name = string.Join(' ', spaceSegments[..^1]);
|
||||
if (!DateTime.TryParse(dateSegments[0], out parseDateTime))
|
||||
continue;
|
||||
personName = IPerson.GetPersonName(name);
|
||||
if (personName is null)
|
||||
continue;
|
||||
personBirthday = new(parseDateTime);
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_PropertyConfiguration.PersonBirthdayFormat, personKey);
|
||||
(age, _) = IAge.GetAge(dateTime.Ticks, personKey);
|
||||
if (dateSegments.Length == 1)
|
||||
death = null;
|
||||
else
|
||||
int age;
|
||||
string name;
|
||||
long personKey;
|
||||
DateTime? death;
|
||||
string ageGroup;
|
||||
bool first = true;
|
||||
string? directory;
|
||||
bool verify = false;
|
||||
string[] dateSegments;
|
||||
DateTime parseDateTime;
|
||||
PersonName? personName;
|
||||
string[] spaceSegments;
|
||||
string personKeyFormatted;
|
||||
bool isDefaultName = false;
|
||||
PersonBirthday personBirthday;
|
||||
string[] family = GetFamily();
|
||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||
foreach (string familyMember in family)
|
||||
{
|
||||
spaceSegments = familyMember[1..].Split(' ');
|
||||
dateSegments = spaceSegments[^1].Split('-');
|
||||
name = string.Join(' ', spaceSegments[..^1]);
|
||||
if (!DateTime.TryParse(dateSegments[0], out parseDateTime))
|
||||
continue;
|
||||
death = parseDateTime;
|
||||
personName = IPerson.GetPersonName(name);
|
||||
if (personName is null)
|
||||
continue;
|
||||
personBirthday = new(parseDateTime);
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_PropertyConfiguration.PersonBirthdayFormat, personKey);
|
||||
(age, _) = IAge.GetAge(dateTime.Ticks, personKey);
|
||||
if (dateSegments.Length == 1)
|
||||
death = null;
|
||||
else
|
||||
{
|
||||
if (!DateTime.TryParse(dateSegments[0], out parseDateTime))
|
||||
continue;
|
||||
death = parseDateTime;
|
||||
}
|
||||
if (age < 25)
|
||||
ageGroup = "1) Less-25";
|
||||
else if (age < 50)
|
||||
ageGroup = "2) Less-50";
|
||||
else if (age < 100)
|
||||
ageGroup = "3) Less-100";
|
||||
else if (age < 200)
|
||||
ageGroup = "4) Less-200";
|
||||
else
|
||||
ageGroup = "5) Else";
|
||||
directory = Path.Combine(saveDirectory, "Norman", ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
genealogicalDataCommunication = new(null, null, null, null, null, null, null, 'U', personBirthday.Value, death, null);
|
||||
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, null, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||
}
|
||||
if (age < 25)
|
||||
ageGroup = "1) Less-25";
|
||||
else if (age < 50)
|
||||
ageGroup = "2) Less-50";
|
||||
else if (age < 100)
|
||||
ageGroup = "3) Less-100";
|
||||
else if (age < 200)
|
||||
ageGroup = "4) Less-200";
|
||||
else
|
||||
ageGroup = "5) Else";
|
||||
directory = Path.Combine(saveDirectory, "Norman", ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
genealogicalDataCommunication = new(null, null, null, null, null, null, null, 'U', personBirthday.Value, death, null);
|
||||
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, null, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
[TestMethod]
|
||||
public void TestMethodGroup()
|
||||
{
|
||||
@ -761,14 +751,18 @@ public partial class UnitTestHardCoded
|
||||
[TestMethod]
|
||||
public void TestMethodRename()
|
||||
{
|
||||
// string[] directories = Directory.GetDirectories(@"D:\2) Images B\Not-Copy-Copy-1e85c0ba", "*;*", SearchOption.AllDirectories);
|
||||
string[] directories = Directory.GetDirectories(@"D:\1) Images A\Images-1e85c0ba", "*;*", SearchOption.AllDirectories);
|
||||
// string[] directories = Directory.GetDirectories(@"D:\2) Images B\Not-Copy-Copy-1e85c0ba", "*", SearchOption.AllDirectories);
|
||||
foreach (string directory in directories.OrderByDescending(l => l.Length - l.Replace(@"\", string.Empty).Length))
|
||||
// string directory = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba";
|
||||
string directory = @"D:\1) Images A\Images-1e85c0ba";
|
||||
// string directory = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
if (!directory.EndsWith(";9"))
|
||||
continue;
|
||||
Directory.Move(directory, $"{directory[..^2]} !9");
|
||||
string[] directories = Directory.GetDirectories(directory, "*;*", SearchOption.AllDirectories);
|
||||
foreach (string subDirectory in directories.OrderByDescending(l => l.Length - l.Replace(@"\", string.Empty).Length))
|
||||
{
|
||||
if (!subDirectory.EndsWith(";9"))
|
||||
continue;
|
||||
Directory.Move(subDirectory, $"{subDirectory[..^2]} !9");
|
||||
}
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
@ -776,9 +770,13 @@ public partial class UnitTestHardCoded
|
||||
[TestMethod]
|
||||
public void TestMethodRenameForUnkown()
|
||||
{
|
||||
string[] files = Directory.GetFiles(@"D:\1) Images A\Images-1e85c0ba-Results\E) Distance\1e85c0ba\(Bad-2023-06-18-less-0.4)", "*.unk", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
File.Move(file, file[..^4]);
|
||||
string directory = @"D:\1) Images A\Images-1e85c0ba-Results\E) Distance\1e85c0ba\(RectInt-2023-06-19-less-0.99)";
|
||||
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||
{
|
||||
string[] files = Directory.GetFiles(directory, "*.unk", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
File.Move(file, file[..^4]);
|
||||
}
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
|
@ -1,113 +0,0 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Configuration.Json;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Phares.Shared;
|
||||
using Serilog;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
using View_by_Distance.Tests.Models;
|
||||
|
||||
namespace View_by_Distance.Tests;
|
||||
|
||||
[TestClass]
|
||||
public class UnitTestIsEnvironment
|
||||
{
|
||||
|
||||
private readonly ILogger _Logger;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly string _WorkingDirectory;
|
||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||
|
||||
public UnitTestIsEnvironment()
|
||||
{
|
||||
ILogger logger;
|
||||
AppSettings appSettings;
|
||||
string workingDirectory;
|
||||
IConfigurationRoot configurationRoot;
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.Development.json");
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
throw new Exception("Working directory name must have a value!");
|
||||
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
logger = Log.ForContext<UnitTestIsEnvironment>();
|
||||
logger.Information("Complete");
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_WorkingDirectory = workingDirectory;
|
||||
_ConfigurationRoot = configurationRoot;
|
||||
}
|
||||
|
||||
private static void NonThrowTryCatch()
|
||||
{
|
||||
try
|
||||
{ throw new Exception(); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodNull()
|
||||
{
|
||||
Assert.IsFalse(_Logger is null);
|
||||
Assert.IsFalse(_AppSettings is null);
|
||||
Assert.IsFalse(_WorkingDirectory is null);
|
||||
Assert.IsFalse(_ConfigurationRoot is null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodTest()
|
||||
{
|
||||
List<string> jsonFiles = new();
|
||||
foreach (IConfigurationProvider configurationProvider in _ConfigurationRoot.Providers)
|
||||
{
|
||||
if (configurationProvider is not JsonConfigurationProvider jsonConfigurationProvider || jsonConfigurationProvider.Source.Path is null)
|
||||
continue;
|
||||
jsonFiles.Add(jsonConfigurationProvider.Source.Path);
|
||||
}
|
||||
Assert.IsTrue(jsonFiles.Any());
|
||||
foreach (string jsonFile in jsonFiles)
|
||||
_ = new IsEnvironment(jsonFile);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
|
||||
public void TestMethodTestCategory()
|
||||
{
|
||||
MethodBase? methodBase = new StackFrame().GetMethod();
|
||||
if (methodBase is not null)
|
||||
{
|
||||
TestCategoryAttribute? testCategoryAttribute = methodBase.GetCustomAttribute<TestCategoryAttribute>();
|
||||
if (testCategoryAttribute is not null)
|
||||
{
|
||||
foreach (string testCategory in testCategoryAttribute.TestCategories)
|
||||
_ = new IsEnvironment(testCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodHardcoded()
|
||||
{
|
||||
_ = new IsEnvironment(isDevelopment: true, isStaging: false, isProduction: false);
|
||||
_ = new IsEnvironment(isDevelopment: false, isStaging: true, isProduction: false);
|
||||
_ = new IsEnvironment(isDevelopment: false, isStaging: false, isProduction: true);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethodAssembly()
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
|
||||
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||
_ = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||
}
|
||||
|
||||
}
|
@ -42,7 +42,8 @@ public class UnitTestResize
|
||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||
.AddUserSecrets<UnitTestResize>();
|
||||
configurationRoot = configurationBuilder.Build();
|
||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||
|
Reference in New Issue
Block a user