diff --git a/Adaptation/.editorconfig b/Adaptation/.editorconfig index 52bdff4..639cf9b 100644 --- a/Adaptation/.editorconfig +++ b/Adaptation/.editorconfig @@ -121,6 +121,7 @@ dotnet_diagnostic.IDE0290.severity = none # Use primary constructor [Distance]cs dotnet_diagnostic.IDE0300.severity = none # IDE0300: Collection initialization can be simplified dotnet_diagnostic.IDE0301.severity = none #IDE0301: Collection initialization can be simplified dotnet_diagnostic.IDE0305.severity = none # IDE0305: Collection initialization can be simplified +dotnet_diagnostic.MSTEST0037.severity = error # MSTEST0037: Use proper 'Assert' methods dotnet_diagnostic.SYSLIB1045.severity = none # SYSLIB1045: diagnostics for regex source generation dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case diff --git a/Adaptation/.vscode/format-report.json b/Adaptation/.vscode/format-report.json index 0637a08..4844ffe 100644 --- a/Adaptation/.vscode/format-report.json +++ b/Adaptation/.vscode/format-report.json @@ -1 +1,20 @@ -[] \ No newline at end of file +[ + { + "DocumentId": { + "ProjectId": { + "Id": "88b6bb05-fef2-487e-bb6c-9ae68922c0bb" + }, + "Id": "63c5cda5-30ee-4e20-9ec8-d45777057452" + }, + "FileName": "MonIn.cs", + "FilePath": "L:\\DevOps\\EAF-Mesa-Integration\\mesafibacklog\\Adaptation\\Infineon\\Monitoring\\MonA\\MonIn.cs", + "FileChanges": [ + { + "LineNumber": 268, + "CharNumber": 17, + "DiagnosticId": "CA1816", + "FormatDescription": "warning CA1816: Change MonIn.Dispose() to call GC.SuppressFinalize(object). This will prevent derived types that introduce a finalizer from needing to re-implement \u0027IDisposable\u0027 to call it." + } + ] + } +] \ No newline at end of file diff --git a/Adaptation/FileHandlers/ADO/ProcessData.cs b/Adaptation/FileHandlers/ADO/ProcessData.cs index b1d7307..00912b1 100644 --- a/Adaptation/FileHandlers/ADO/ProcessData.cs +++ b/Adaptation/FileHandlers/ADO/ProcessData.cs @@ -28,7 +28,6 @@ public class ProcessData : IProcessData { } if (url is null) throw new ArgumentNullException(nameof(url)); - fileInfoCollection.Clear(); _Details = new List(); _Log = LogManager.GetLogger(typeof(ProcessData)); WriteFiles(fileRead, logistics, targetFileLocation, fileInfoCollection); diff --git a/Adaptation/FileHandlers/APC/FileRead.cs b/Adaptation/FileHandlers/APC/FileRead.cs index 5e2ab67..2595250 100644 --- a/Adaptation/FileHandlers/APC/FileRead.cs +++ b/Adaptation/FileHandlers/APC/FileRead.cs @@ -120,15 +120,15 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = GetDuplicatorDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) FileCopy(reportFullPath, dateTime, descriptions); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/Archive/FileRead.cs b/Adaptation/FileHandlers/Archive/FileRead.cs index 6dfdff4..c14a09f 100644 --- a/Adaptation/FileHandlers/Archive/FileRead.cs +++ b/Adaptation/FileHandlers/Archive/FileRead.cs @@ -144,15 +144,15 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = GetDuplicatorDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) MoveArchive(reportFullPath, dateTime); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/IQSSi/FileRead.cs b/Adaptation/FileHandlers/IQSSi/FileRead.cs index 12bc214..77ca839 100644 --- a/Adaptation/FileHandlers/IQSSi/FileRead.cs +++ b/Adaptation/FileHandlers/IQSSi/FileRead.cs @@ -119,15 +119,15 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = GetDuplicatorDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) FileCopy(reportFullPath, dateTime, descriptions); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/Kanban/ProcessData.cs b/Adaptation/FileHandlers/Kanban/ProcessData.cs index 2f91567..b78c411 100644 --- a/Adaptation/FileHandlers/Kanban/ProcessData.cs +++ b/Adaptation/FileHandlers/Kanban/ProcessData.cs @@ -28,7 +28,6 @@ public class ProcessData : IProcessData { } if (url is null) throw new ArgumentNullException(nameof(url)); - fileInfoCollection.Clear(); _Details = new List(); _Log = LogManager.GetLogger(typeof(ProcessData)); WriteFiles(fileRead, logistics, calendar, targetFileLocation, fileInfoCollection); diff --git a/Adaptation/FileHandlers/Markdown/ProcessData.cs b/Adaptation/FileHandlers/Markdown/ProcessData.cs index 495abe4..d3b156a 100644 --- a/Adaptation/FileHandlers/Markdown/ProcessData.cs +++ b/Adaptation/FileHandlers/Markdown/ProcessData.cs @@ -26,7 +26,6 @@ public class ProcessData : IProcessData { if (fileRead.IsEAFHosted) { } - fileInfoCollection.Clear(); _Details = new List(); _Log = LogManager.GetLogger(typeof(ProcessData)); WriteFiles(fileRead, logistics, url, workItemTypes, targetFileLocation, fileInfoCollection); diff --git a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs index 2d8a495..a6135db 100644 --- a/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs +++ b/Adaptation/FileHandlers/MoveMatchingFiles/FileRead.cs @@ -244,8 +244,8 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results = new(string.Empty, null, null, new List()); - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); int numberLength = 2; long ticks = dateTime.Ticks; diff --git a/Adaptation/FileHandlers/OpenInsight/FileRead.cs b/Adaptation/FileHandlers/OpenInsight/FileRead.cs index d02bdef..5706703 100644 --- a/Adaptation/FileHandlers/OpenInsight/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsight/FileRead.cs @@ -118,15 +118,15 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = json.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) SaveOpenInsightFile(reportFullPath, dateTime, descriptions, tests); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs index 41d3c6b..8c0b66a 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/FileRead.cs @@ -129,15 +129,15 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = json.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) SendData(reportFullPath, dateTime, descriptions); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs index f29f18a..2242792 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs @@ -146,15 +146,15 @@ public class FileRead : Shared.FileRead, IFileRead if (dateTime == DateTime.MinValue) throw new ArgumentNullException(nameof(dateTime)); Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = json.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) PostOpenInsightMetrologyViewerAttachments(descriptions); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/Processed/FileRead.cs b/Adaptation/FileHandlers/Processed/FileRead.cs index 02ab44e..5dd6706 100644 --- a/Adaptation/FileHandlers/Processed/FileRead.cs +++ b/Adaptation/FileHandlers/Processed/FileRead.cs @@ -143,13 +143,13 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = json.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) DirectoryMove(reportFullPath, dateTime, descriptions); else if (!_IsEAFHosted) diff --git a/Adaptation/FileHandlers/SPaCe/FileRead.cs b/Adaptation/FileHandlers/SPaCe/FileRead.cs index a8155b6..dc59c67 100644 --- a/Adaptation/FileHandlers/SPaCe/FileRead.cs +++ b/Adaptation/FileHandlers/SPaCe/FileRead.cs @@ -117,15 +117,15 @@ public class FileRead : Shared.FileRead, IFileRead private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) { Tuple> results; - Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); - _Logistics = new Logistics(reportFullPath, pdsf.Item1); + ProcessData processData = ProcessDataStandardFormat.GetProcessData(reportFullPath); + _Logistics = new Logistics(reportFullPath, processData.Logistics); SetFileParameterLotIDToLogisticsMID(); - JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(pdsf); + JsonElement[] jsonElements = ProcessDataStandardFormat.GetArray(processData); List descriptions = GetDuplicatorDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) FileCopy(reportFullPath, dateTime, descriptions); - results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); + results = new Tuple>(processData.Logistics, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/FileHandlers/json/ProcessData.cs b/Adaptation/FileHandlers/json/ProcessData.cs index 11df6d2..d452f14 100644 --- a/Adaptation/FileHandlers/json/ProcessData.cs +++ b/Adaptation/FileHandlers/json/ProcessData.cs @@ -19,7 +19,6 @@ public class ProcessData : IProcessData Logistics logistics, List fileInfoCollection) { - fileInfoCollection.Clear(); _Details = new List(); Parse(); } diff --git a/Adaptation/MESAFIBACKLOG.Tests.csproj b/Adaptation/MESAFIBACKLOG.Tests.csproj index 70b2d67..0d55b25 100644 --- a/Adaptation/MESAFIBACKLOG.Tests.csproj +++ b/Adaptation/MESAFIBACKLOG.Tests.csproj @@ -94,7 +94,7 @@ - + NU1701 diff --git a/Adaptation/MESAFIBACKLOG.yml b/Adaptation/MESAFIBACKLOG.yml index 4953d2e..1f9bda1 100644 --- a/Adaptation/MESAFIBACKLOG.yml +++ b/Adaptation/MESAFIBACKLOG.yml @@ -25,7 +25,7 @@ stages: nugetSource: "https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/" jobs: - - job: SetupEnviroment + - job: SetupEnvironment steps: - script: | echo $(Build.BuildId) @@ -51,7 +51,7 @@ stages: - job: BuildDebug dependsOn: - - SetupEnviroment + - SetupEnvironment steps: - script: | set configuration=Debug @@ -66,7 +66,7 @@ stages: - job: BuildRelease dependsOn: - - SetupEnviroment + - SetupEnvironment steps: - script: | set configuration=Release @@ -98,7 +98,7 @@ stages: - job: TestDebug dependsOn: - - SetupEnviroment + - SetupEnvironment - BuildDebug - BuildRelease steps: @@ -168,7 +168,7 @@ stages: nugetSource: "https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/" jobs: - - job: SetupEnviroment + - job: SetupEnvironment steps: - script: | echo $(Build.BuildId) @@ -194,7 +194,7 @@ stages: - job: BuildRelease dependsOn: - - SetupEnviroment + - SetupEnvironment steps: - script: | set configuration=Release @@ -226,7 +226,7 @@ stages: - job: TestRelease dependsOn: - - SetupEnviroment + - SetupEnvironment - BuildRelease steps: - script: | diff --git a/Adaptation/Shared/ProcessData.cs b/Adaptation/Shared/ProcessData.cs new file mode 100644 index 0000000..cbee8cd --- /dev/null +++ b/Adaptation/Shared/ProcessData.cs @@ -0,0 +1,21 @@ +namespace Adaptation.Shared; + +public class ProcessData +{ + + protected readonly string _Logistics; + protected readonly string[] _Columns; + protected readonly string[] _BodyLines; + + public string Logistics => _Logistics; + public string[] Columns => _Columns; + public string[] BodyLines => _BodyLines; + + public ProcessData(string logistics, string[] columns, string[] bodyLines) + { + _Logistics = logistics; + _Columns = columns; + _BodyLines = bodyLines; + } + +} \ No newline at end of file diff --git a/Adaptation/Shared/ProcessDataStandardFormat.cs b/Adaptation/Shared/ProcessDataStandardFormat.cs index 6101d68..894f23b 100644 --- a/Adaptation/Shared/ProcessDataStandardFormat.cs +++ b/Adaptation/Shared/ProcessDataStandardFormat.cs @@ -86,7 +86,7 @@ public class ProcessDataStandardFormat return result; } - public static Tuple GetLogisticsColumnsAndBody(string reportFullPath, string[] lines = null) + public static ProcessData GetProcessData(string reportFullPath, string[] lines = null) { string segment; List body = new(); @@ -137,24 +137,23 @@ public class ProcessDataStandardFormat break; } } - return new Tuple(logistics.ToString(), columns.ToArray(), body.ToArray()); + return new(logistics.ToString(), columns.ToArray(), body.ToArray()); } - public static JsonElement[] GetArray(Tuple pdsf, bool lookForNumbers = false) + public static JsonElement[] GetArray(ProcessData processData, bool lookForNumbers = false) { JsonElement[] results; - string logistics = pdsf.Item1; - string[] columns = pdsf.Item2; - string[] bodyLines = pdsf.Item3; - if (bodyLines.Length == 0 || !bodyLines[0].Contains('\t')) + if (processData.BodyLines.Length == 0 || !processData.BodyLines[0].Contains('\t')) results = JsonSerializer.Deserialize("[]"); else { string value; string[] segments; + List lines = new(); StringBuilder stringBuilder = new(); - foreach (string bodyLine in bodyLines) + foreach (string bodyLine in processData.BodyLines) { + _ = stringBuilder.Clear(); _ = stringBuilder.Append('{'); segments = bodyLine.Trim().Split('\t'); if (!lookForNumbers) @@ -162,7 +161,7 @@ public class ProcessDataStandardFormat for (int c = 1; c < segments.Length; c++) { value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\"); - _ = stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\","); + _ = stringBuilder.Append('"').Append(processData.Columns[c]).Append("\":\"").Append(value).Append("\","); } } else @@ -171,49 +170,48 @@ public class ProcessDataStandardFormat { value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\"); if (string.IsNullOrEmpty(value)) - _ = stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append("null,"); + _ = stringBuilder.Append('"').Append(processData.Columns[c]).Append("\":").Append(value).Append("null,"); else if (value.All(char.IsDigit)) - _ = stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append(','); + _ = stringBuilder.Append('"').Append(processData.Columns[c]).Append("\":").Append(value).Append(','); else - _ = stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\","); + _ = stringBuilder.Append('"').Append(processData.Columns[c]).Append("\":\"").Append(value).Append("\","); } } _ = stringBuilder.Remove(stringBuilder.Length - 1, 1); - _ = stringBuilder.AppendLine("},"); + _ = stringBuilder.AppendLine("}"); + lines.Add(stringBuilder.ToString()); } - _ = stringBuilder.Remove(stringBuilder.Length - 3, 3); - results = JsonSerializer.Deserialize(string.Concat("[", stringBuilder, "]")); + string json = $"[{string.Join(",", lines)}]"; + results = JsonSerializer.Deserialize(json); } return results; } - public static Dictionary> GetDictionary(Tuple pdsf) + public static Dictionary> GetDictionary(ProcessData processData) { Dictionary> results = new(); string[] segments; - string[] columns = pdsf.Item2; - string[] bodyLines = pdsf.Item3; - foreach (string column in columns) + foreach (string column in processData.Columns) results.Add(column, new List()); - foreach (string bodyLine in bodyLines) + foreach (string bodyLine in processData.BodyLines) { segments = bodyLine.Split('\t'); for (int c = 1; c < segments.Length; c++) { - if (c >= columns.Length) + if (c >= processData.Columns.Length) continue; - results[columns[c]].Add(segments[c]); + results[processData.Columns[c]].Add(segments[c]); } } return results; } - public static Tuple>>> GetTestDictionary(Tuple pdsf) + public static Tuple>>> GetTestDictionary(ProcessData processData) { Dictionary>> results = new(); List collection; string testColumn = nameof(Test); - Dictionary> keyValuePairs = GetDictionary(pdsf); + Dictionary> keyValuePairs = GetDictionary(processData); if (!keyValuePairs.TryGetValue(testColumn, out collection)) throw new Exception(); int min; @@ -254,7 +252,7 @@ public class ProcessDataStandardFormat } } } - return new Tuple>>>(pdsf.Item1, results); + return new Tuple>>>(processData.Logistics, results); } private static string GetString(SearchFor searchFor, bool addSpaces, char separator = ' ') diff --git a/Adaptation/_Tests/Shared/AdaptationTesting.cs b/Adaptation/_Tests/Shared/AdaptationTesting.cs index 8a341d4..64393eb 100644 --- a/Adaptation/_Tests/Shared/AdaptationTesting.cs +++ b/Adaptation/_Tests/Shared/AdaptationTesting.cs @@ -1090,60 +1090,60 @@ public class AdaptationTesting : ISMTP return results; } - internal static Tuple GetLogisticsColumnsAndBody(string fileFullName) + internal static ProcessData GetProcessData(string fileFullName) { - Tuple 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 GetLogisticsColumnsAndBody(string searchDirectory, string searchPattern) + internal static ProcessData GetProcessData(string searchDirectory, string searchPattern) { - Tuple 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 GetLogisticsColumnsAndBody(IFileRead fileRead, Logistics logistics, Tuple> extractResult, Tuple pdsf) + internal static ProcessData GetProcessData(IFileRead fileRead, Logistics logistics, Tuple> extractResult, ProcessData processData) { - Tuple 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 pdsf, Tuple 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 pdsf, Tuple 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 pdsf, Tuple 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(), Array.Empty())); + _ = GetProcessData(fileRead, logistics, extractResult, new(string.Empty, Array.Empty(), Array.Empty())); else { Assert.IsTrue(extractResult.Item3.Length > 0, "extractResult Array Length check!"); - Tuple pdsf = GetLogisticsColumnsAndBody(variables[2], variables[4]); - Tuple 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]); } diff --git a/Adaptation/_Tests/Static/ALIGNMENT.cs b/Adaptation/_Tests/Static/ALIGNMENT.cs index 5dd0478..5a94ae4 100644 --- a/Adaptation/_Tests/Static/ALIGNMENT.cs +++ b/Adaptation/_Tests/Static/ALIGNMENT.cs @@ -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 diff --git a/Adaptation/_Tests/Static/BACKLOG.cs b/Adaptation/_Tests/Static/BACKLOG.cs index a757a6f..60b4eb2 100644 --- a/Adaptation/_Tests/Static/BACKLOG.cs +++ b/Adaptation/_Tests/Static/BACKLOG.cs @@ -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 diff --git a/Adaptation/_Tests/Static/MESAFIBACKLOG.cs b/Adaptation/_Tests/Static/MESAFIBACKLOG.cs index 6c7ce4a..484e2c4 100644 --- a/Adaptation/_Tests/Static/MESAFIBACKLOG.cs +++ b/Adaptation/_Tests/Static/MESAFIBACKLOG.cs @@ -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 diff --git a/MESAFIBACKLOG.csproj b/MESAFIBACKLOG.csproj index bce62c4..6fa2658 100644 --- a/MESAFIBACKLOG.csproj +++ b/MESAFIBACKLOG.csproj @@ -186,6 +186,7 @@ +