Person Containers Inner Groups

This commit is contained in:
2023-04-19 17:42:35 -07:00
parent b97a939c58
commit e5484bdcc5
4 changed files with 152 additions and 93 deletions

View File

@ -249,7 +249,6 @@ public partial class UnitTestHardCoded
{
List<string> mappedLines;
Dictionary<string, List<string>> individuals;
PersonBirthday personBirthday = new(DateTime.Now);
GenealogicalDataCommunication genealogicalDataCommunication;
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
List<(bool, string)> genealogicalDataCommunicationFiles = new()
@ -272,7 +271,7 @@ public partial class UnitTestHardCoded
{
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(personBirthday, genealogicalDataCommunicationLines);
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(genealogicalDataCommunicationLines);
Assert.IsNotNull(genealogicalDataCommunication.Name);
}
mappedLines = IGenealogicalDataCommunication.GetMappedLines(genealogicalDataCommunicationFile, requireNickName);
@ -290,10 +289,10 @@ public partial class UnitTestHardCoded
string ageGroup;
string fileName;
string? directory;
bool first = true;
PersonName? personName;
string personKeyFormatted;
bool isDefaultName = false;
PersonBirthday personBirthday;
DateTime dateTime = DateTime.Now;
Dictionary<string, List<string>> individuals;
GenealogicalDataCommunication genealogicalDataCommunication;
@ -318,18 +317,16 @@ public partial class UnitTestHardCoded
(_, individuals, _) = IGenealogicalDataCommunication.GetIndividuals(genealogicalDataCommunicationFile, requireNickName);
foreach (KeyValuePair<string, List<string>> keyValuePair in individuals)
{
personBirthday = new(dateTime);
genealogicalDataCommunicationLines = IGenealogicalDataCommunication.GetGenealogicalDataCommunicationLines(keyValuePair.Value);
Assert.IsNotNull(genealogicalDataCommunicationLines.Name);
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(personBirthday, genealogicalDataCommunicationLines);
genealogicalDataCommunication = IGenealogicalDataCommunication.GetGenealogicalDataCommunication(genealogicalDataCommunicationLines);
Assert.IsNotNull(genealogicalDataCommunication.Name);
if (genealogicalDataCommunication.Birth is null)
continue;
personName = IPersonName.GetPersonName(genealogicalDataCommunication);
if (personName is null)
continue;
personBirthday = new(genealogicalDataCommunication.Birth.Value);
personKey = personBirthday.Value.Ticks;
personKey = genealogicalDataCommunication.Birth.Value.Ticks;
(age, _) = IAge.GetAge(dateTime.Ticks, personKey);
personKeyFormatted = IPersonBirthday.GetFormatted(_PropertyConfiguration.PersonBirthdayFormat, personKey);
if (age < 25)
@ -345,13 +342,13 @@ public partial class UnitTestHardCoded
directory = Path.Combine(saveDirectory, fileName, ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personBirthday, personName, keyValuePair.Value, isDefaultName, directory, genealogicalDataCommunication, verify);
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, keyValuePair.Value, isDefaultName, directory, genealogicalDataCommunication, verify, first);
}
}
NonThrowTryCatch();
}
private 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",
@ -645,12 +642,11 @@ public partial class UnitTestHardCoded
public void TestMethodFamily()
{
int age;
char sex;
int hours;
bool alive;
string name;
long personKey;
DateTime? death;
string ageGroup;
bool first = true;
string? directory;
bool verify = false;
string[] dateSegments;
@ -658,17 +654,14 @@ public partial class UnitTestHardCoded
PersonName? personName;
string[] spaceSegments;
string personKeyFormatted;
List<string> lines = new();
bool isDefaultName = false;
PersonBirthday personBirthday;
string[] family = GetFamily();
DateTime dateTime = DateTime.Now;
GenealogicalDataCommunication genealogicalDataCommunication;
string saveDirectory = $"D:/1) Images A/Images-9b89679-Results/A2) People/9b89679/([])/Norman-{dateTime.Ticks}";
foreach (string familyMember in family)
{
sex = familyMember[0];
if (sex is not 'U' and not 'F' and not 'M')
continue;
spaceSegments = familyMember[1..].Split(' ');
dateSegments = spaceSegments[^1].Split('-');
name = string.Join(' ', spaceSegments[..^1]);
@ -678,22 +671,17 @@ public partial class UnitTestHardCoded
if (personName is null)
continue;
personBirthday = new(parseDateTime);
if (dateSegments.Length == 1)
{
lines.Add($"{name}\t{sex}\t{personBirthday.Value:yyyy-MM-dd}\tnull");
alive = true;
}
else
{
if (!DateTime.TryParse(dateSegments[1], out parseDateTime))
continue;
alive = false;
lines.Add($"{name}\t{sex}\t{personBirthday.Value:yyyy-MM-dd}\t{parseDateTime:yyyy-MM-dd}");
}
hours = IPersonBirthday.GetHour(alive, sex);
personKey = personBirthday.Value.AddHours(hours).Ticks;
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)
@ -707,9 +695,33 @@ public partial class UnitTestHardCoded
directory = Path.Combine(saveDirectory, "Norman", ageGroup, $"{personName.First.Value} {personName.Last.Value}^{age}", personKeyFormatted);
if (!Directory.Exists(directory))
_ = Directory.CreateDirectory(directory);
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personBirthday, personName, null, isDefaultName, directory, null, verify);
genealogicalDataCommunication = new(null, null, null, null, null, null, null, 'U', personBirthday.Value, death, null);
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, null, isDefaultName, directory, genealogicalDataCommunication, verify, first);
}
File.WriteAllLines(Path.Combine(saveDirectory, "tsv.txt"), lines);
NonThrowTryCatch();
}
[TestMethod]
public void TestMethodGroup()
{
// const int Number = 0;
// const int Partial = 1;
// const int Approximate = 5;
// const int Exact = 9;
// //
// const int Alive = 0;
// const int Dead = 5;
// //
// const int Unknown = 0;
// const int Male = 5;
// const int Female = 9;
// foreach (var item in new string[] { "Number", "Partial", "Approximate", "Exact" })
foreach (string status in new string[] { "Alive", "Dead" })
{
foreach (string sex in new string[] { "Unknown", "Male", "Female" })
_ = Directory.CreateDirectory($"D:/{status}-{sex}");
}
NonThrowTryCatch();
}