ProcessData over Tuple

This commit is contained in:
2025-03-17 15:07:57 -07:00
parent 534d0ccc5c
commit e02b70e258
24 changed files with 151 additions and 115 deletions

View File

@ -1090,60 +1090,60 @@ public class AdaptationTesting : ISMTP
return results;
}
internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string fileFullName)
internal static ProcessData GetProcessData(string fileFullName)
{
Tuple<string, string[], string[]> results;
results = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(fileFullName);
Assert.IsFalse(string.IsNullOrEmpty(results.Item1));
Assert.IsTrue(results.Item2.Length > 0, "Column check");
Assert.IsTrue(results.Item3.Length > 0, "Body check");
ProcessData results;
results = ProcessDataStandardFormat.GetProcessData(fileFullName);
Assert.IsFalse(string.IsNullOrEmpty(results.Logistics));
Assert.IsTrue(results.Columns.Length > 0, "Column check");
Assert.IsTrue(results.BodyLines.Length > 0, "Body check");
return results;
}
internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string searchDirectory, string searchPattern)
internal static ProcessData GetProcessData(string searchDirectory, string searchPattern)
{
Tuple<string, string[], string[]> results;
ProcessData results;
if (searchPattern.Length > 3 && !searchPattern.Contains('*') && File.Exists(searchPattern))
results = GetLogisticsColumnsAndBody(searchPattern);
results = GetProcessData(searchPattern);
else
{
string[] pdsfFiles;
pdsfFiles = Directory.GetFiles(searchDirectory, searchPattern, SearchOption.TopDirectoryOnly);
if (pdsfFiles.Length == 0)
_ = Process.Start("explorer.exe", searchDirectory);
Assert.IsTrue(pdsfFiles.Length != 0, "GetFiles check");
results = GetLogisticsColumnsAndBody(pdsfFiles[0]);
Assert.AreNotEqual(0, pdsfFiles.Length, "GetFiles check");
results = GetProcessData(pdsfFiles[0]);
}
Assert.IsFalse(string.IsNullOrEmpty(results.Item1));
Assert.IsTrue(results.Item2.Length > 0, "Column check");
Assert.IsTrue(results.Item3.Length > 0, "Body check");
Assert.IsFalse(string.IsNullOrEmpty(results.Logistics));
Assert.IsTrue(results.Columns.Length > 0, "Column check");
Assert.IsTrue(results.BodyLines.Length > 0, "Body check");
return results;
}
internal static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(IFileRead fileRead, Logistics logistics, Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult, Tuple<string, string[], string[]> pdsf)
internal static ProcessData GetProcessData(IFileRead fileRead, Logistics logistics, Tuple<string, Test[], JsonElement[], List<FileInfo>> extractResult, ProcessData processData)
{
Tuple<string, string[], string[]> results;
string text = ProcessDataStandardFormat.GetPDSFText(fileRead, logistics, extractResult.Item3, logisticsText: pdsf.Item1);
ProcessData results;
string text = ProcessDataStandardFormat.GetPDSFText(fileRead, logistics, extractResult.Item3, logisticsText: processData.Logistics);
string[] lines = text.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
results = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(logistics.ReportFullPath, lines);
Assert.IsFalse(string.IsNullOrEmpty(results.Item1));
Assert.IsTrue(results.Item2.Length > 0, "Column check");
Assert.IsTrue(results.Item3.Length > 0, "Body check");
results = ProcessDataStandardFormat.GetProcessData(logistics.ReportFullPath, lines);
Assert.IsFalse(string.IsNullOrEmpty(results.Logistics));
Assert.IsTrue(results.Columns.Length > 0, "Column check");
Assert.IsTrue(results.BodyLines.Length > 0, "Body check");
return results;
}
internal static string[] GetItem2(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew)
internal static string[] GetItem2(ProcessData processData, ProcessData processDataNew)
{
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
string jsonOld = JsonSerializer.Serialize(pdsf.Item2, pdsf.Item2.GetType(), jsonSerializerOptions);
string jsonNew = JsonSerializer.Serialize(pdsfNew.Item2, pdsfNew.Item2.GetType(), jsonSerializerOptions);
string jsonOld = JsonSerializer.Serialize(processData.Columns, processData.Columns.GetType(), jsonSerializerOptions);
string jsonNew = JsonSerializer.Serialize(processDataNew.Columns, processDataNew.Columns.GetType(), jsonSerializerOptions);
return new string[] { jsonOld, jsonNew };
}
internal static string[] GetItem3(Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew)
internal static string[] GetItem3(ProcessData processData, ProcessData processDataNew)
{
string joinOld = string.Join(System.Environment.NewLine, from l in pdsf.Item3 select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
string joinNew = string.Join(System.Environment.NewLine, from l in pdsfNew.Item3 select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
string joinOld = string.Join(System.Environment.NewLine, from l in processData.BodyLines select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
string joinNew = string.Join(System.Environment.NewLine, from l in processDataNew.BodyLines select string.Join('\t', from t in l.Split('\t') where !t.Contains(@"\\") select t));
return new string[] { joinOld, joinNew };
}
@ -1219,13 +1219,13 @@ public class AdaptationTesting : ISMTP
}
}
internal static void CompareSave(string textFileDirectory, Tuple<string, string[], string[]> pdsf, Tuple<string, string[], string[]> pdsfNew)
internal static void CompareSave(string textFileDirectory, ProcessData processData, ProcessData processDataNew)
{
if (pdsf.Item1 != pdsfNew.Item1)
if (processData.Logistics != processDataNew.Logistics)
{
_ = Process.Start("explorer.exe", textFileDirectory);
File.WriteAllText(Path.Combine(textFileDirectory, "0.dat"), pdsf.Item1);
File.WriteAllText(Path.Combine(textFileDirectory, "1.dat"), pdsfNew.Item1);
File.WriteAllText(Path.Combine(textFileDirectory, "0.dat"), processData.Logistics);
File.WriteAllText(Path.Combine(textFileDirectory, "1.dat"), processDataNew.Logistics);
}
}
@ -1252,20 +1252,20 @@ public class AdaptationTesting : ISMTP
Assert.IsNotNull(extractResult.Item3);
Assert.IsNotNull(extractResult.Item4);
if (!validatePDSF)
_ = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, new(string.Empty, Array.Empty<string>(), Array.Empty<string>()));
_ = GetProcessData(fileRead, logistics, extractResult, new(string.Empty, Array.Empty<string>(), Array.Empty<string>()));
else
{
Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!");
Tuple<string, string[], string[]> pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]);
Tuple<string, string[], string[]> pdsfNew = GetLogisticsColumnsAndBody(fileRead, logistics, extractResult, pdsf);
CompareSave(variables[5], pdsf, pdsfNew);
Assert.IsTrue(pdsf.Item1 == pdsfNew.Item1, "Item1 check!");
string[] json = GetItem2(pdsf, pdsfNew);
ProcessData processData = GetProcessData(variables[2], variables[4]);
ProcessData processDataNew = GetProcessData(fileRead, logistics, extractResult, processData);
CompareSave(variables[5], processData, processDataNew);
Assert.AreEqual(processDataNew.Logistics, processData.Logistics, "Item1 check!");
string[] json = GetItem2(processData, processDataNew);
CompareSaveJSON(variables[5], json);
Assert.IsTrue(json[0] == json[1], "Item2 check!");
string[] join = GetItem3(pdsf, pdsfNew);
Assert.AreEqual(json[1], json[0], "Item2 check!");
string[] join = GetItem3(processData, processDataNew);
CompareSaveTSV(variables[5], join);
Assert.IsTrue(join[0] == join[1], "Item3 (Join) check!");
Assert.AreEqual(join[1], join[0], "Item3 (Join) check!");
}
UpdatePassDirectory(variables[2]);
}

View File

@ -51,7 +51,7 @@ public class ALIGNMENT : LoggingUnitTesting, IDisposable
public void TestDateTime()
{
DateTime dateTime = DateTime.Now;
Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString());
Assert.AreEqual(dateTime.ToString(), dateTime.ToString("M/d/yyyy h:mm:ss tt"));
}
#if DEBUG

View File

@ -51,7 +51,7 @@ public class BACKLOG : LoggingUnitTesting, IDisposable
public void TestDateTime()
{
DateTime dateTime = DateTime.Now;
Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString());
Assert.AreEqual(dateTime.ToString(), dateTime.ToString("M/d/yyyy h:mm:ss tt"));
}
#if DEBUG

View File

@ -51,7 +51,7 @@ public class MESAFIBACKLOG : LoggingUnitTesting, IDisposable
public void TestDateTime()
{
DateTime dateTime = DateTime.Now;
Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString());
Assert.AreEqual(dateTime.ToString(), dateTime.ToString("M/d/yyyy h:mm:ss tt"));
}
#if DEBUG