From c1d2b619eef0002cecfa6df27658ea3d0de5df7c Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Thu, 29 Sep 2022 18:20:21 -0700 Subject: [PATCH] R53 and R55 --- Adaptation/FileHandlers/jpeg/FileRead.cs | 7 +- Adaptation/FileHandlers/jpeg/ProcessData.cs | 56 ++++-- Adaptation/_Tests/Shared/AdaptationTesting.cs | 9 + Adaptation/_Tests/Static/EAF.cs | 190 ++++++++++++++++++ Adaptation/_Tests/Static/xml.cs | 74 +++++++ 5 files changed, 319 insertions(+), 17 deletions(-) create mode 100644 Adaptation/_Tests/Static/EAF.cs create mode 100644 Adaptation/_Tests/Static/xml.cs diff --git a/Adaptation/FileHandlers/jpeg/FileRead.cs b/Adaptation/FileHandlers/jpeg/FileRead.cs index a4c7067..5495482 100644 --- a/Adaptation/FileHandlers/jpeg/FileRead.cs +++ b/Adaptation/FileHandlers/jpeg/FileRead.cs @@ -22,6 +22,8 @@ public class FileRead : Shared.FileRead, IFileRead protected readonly Size _Size; protected readonly int _StartX; protected readonly int _StartY; + protected readonly int _OffSetX; + protected readonly int _OffSetY; protected string _TessDataDirectory; protected List _PreviousTotalDeltaCollection; protected readonly Dictionary _Reactors; @@ -77,8 +79,9 @@ public class FileRead : Shared.FileRead, IFileRead _EndY = int.Parse(endY); _ColorCollections = new(); _PreviousTotalDeltaCollection = new(); + (_OffSetX, _OffSetY) = ProcessData.GetOffSet(_FileConnectorConfiguration.SourceDirectoryCloaking); string masterImageDirectory = GetPropertyValue(cellInstanceConnectionName, modelObjectParameters, "Path.Memory.Master.Images"); - List<(string File, Size Size, Color[] Colors)> colorCollections = ProcessData.GetColorCollections(_StartX, _StartY, _EndX, _EndY, masterImageDirectory); + List<(string File, Size Size, Color[] Colors)> colorCollections = ProcessData.GetColorCollections(_StartX, _StartY, _EndX, _EndY, _OffSetX, _OffSetY, masterImageDirectory); int[] distinctSizes = (from l in colorCollections select l.Size.Width * l.Size.Height).Distinct().ToArray(); if (distinctSizes.Length != 1) throw new Exception($"All Master Images must be the same size{Environment.NewLine}{string.Join(Environment.NewLine, distinctSizes)}"); @@ -160,7 +163,7 @@ public class FileRead : Shared.FileRead, IFileRead results.Item4.Add(_Logistics.FileInfo); else { - IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _StartX, _StartY, _EndX, _EndY, _Size, _ColorCollections); + IProcessData iProcessData = new ProcessData(this, _Logistics, results.Item4, _StartX, _StartY, _EndX, _EndY, _OffSetX, _OffSetY, _Size, _ColorCollections); if (iProcessData is not ProcessData processData) throw new Exception(string.Concat("A) No Data - ", dateTime.Ticks)); string lastText = Regex.Replace(_LastText, @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]", "_").Split('\r')[0].Split('\n')[0]; diff --git a/Adaptation/FileHandlers/jpeg/ProcessData.cs b/Adaptation/FileHandlers/jpeg/ProcessData.cs index 4ab5ba0..4a45b74 100644 --- a/Adaptation/FileHandlers/jpeg/ProcessData.cs +++ b/Adaptation/FileHandlers/jpeg/ProcessData.cs @@ -30,7 +30,7 @@ public class ProcessData : IProcessData List Shared.Properties.IProcessData.Details => _Details; - public ProcessData(IFileRead fileRead, Logistics logistics, List fileInfoCollection, int startX, int startY, int endX, int endY, Size size, List> colorCollections) + public ProcessData(IFileRead fileRead, Logistics logistics, List fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, Size size, List> colorCollections) { if (logistics is null) { } @@ -39,7 +39,25 @@ public class ProcessData : IProcessData _Details = new List(); MesEntity = logistics.MesEntity; _Log = LogManager.GetLogger(typeof(ProcessData)); - Parse(fileRead, fileInfoCollection, startX, startY, endX, endY, size, colorCollections); + Parse(fileRead, fileInfoCollection, startX, startY, endX, endY, offSetX, offSetY, size, colorCollections); + } + + internal static (int, int) GetOffSet(string sourceDirectoryCloaking) + { + int offSetX; + int offSetY; + string[] offset = sourceDirectoryCloaking.Split('x'); + if (offset.Length != 2 || !int.TryParse(offset[0], out int x) || !int.TryParse(offset[1], out int y)) + { + offSetX = 0; + offSetY = 0; + } + else + { + offSetX = x; + offSetY = y; + } + return new(offSetX, offSetY); } private static string Get(string value, bool useSplitForMID) @@ -105,16 +123,20 @@ public class ProcessData : IProcessData #nullable enable #pragma warning disable CA1416 - private static (Size, Color[]) Get(string reportFullPath, int startX, int startY, int endX, int endY) + private static (Size, Color[]) Get(string reportFullPath, int startX, int startY, int endX, int endY, int offSetX, int offSetY) { Color color; List colors = new(); + int startXValue = startX + offSetX; + int startYValue = startY + offSetY; + int endXValue = endX + offSetX; + int endYValue = endY + offSetY; using Bitmap? bitmap = Image.FromFile(reportFullPath) as Bitmap; if (bitmap is null) throw new Exception($"Couldn't load image from <{reportFullPath}>"); - for (int x = startX; x < endX; x++) + for (int x = startXValue; x < endXValue; x++) { - for (int y = startY; y < endY; y++) + for (int y = startYValue; y < endYValue; y++) { color = bitmap.GetPixel(x, y); colors.Add(color); @@ -138,12 +160,16 @@ public class ProcessData : IProcessData return imageFormat; } - private static (Color[], int, int) Get(IFileRead fileRead, List fileInfoCollection, int startX, int startY, int endX, int endY, string extension, Size size) + private static (Color[], int, int) Get(IFileRead fileRead, List fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, string extension, Size size) { Color color; List colors = new(); MemoryStream memoryStream = new(); - Bitmap selectedBitmap = new(endX - startX, endY - startY); + int startXValue = startX + offSetX; + int startYValue = startY + offSetY; + int endXValue = endX + offSetX; + int endYValue = endY + offSetY; + Bitmap selectedBitmap = new(endXValue - startXValue, endYValue - startYValue); System.Drawing.Imaging.ImageFormat imageFormat = Get(extension); using Bitmap? bitmap = Image.FromFile(fileRead.ReportFullPath) as Bitmap; string saveFileName = Path.ChangeExtension(fileRead.ReportFullPath, extension); @@ -151,13 +177,13 @@ public class ProcessData : IProcessData throw new Exception($"Couldn't load image from <{fileRead.ReportFullPath}>"); if (!size.Equals(bitmap.Size)) throw new Exception("Source size doesn't match master image size "); - for (int x = startX; x < endX; x++) + for (int x = startXValue; x < endXValue; x++) { - for (int y = startY; y < endY; y++) + for (int y = startYValue; y < endYValue; y++) { color = bitmap.GetPixel(x, y); colors.Add(color); - selectedBitmap.SetPixel(x - startX, y - startY, color); + selectedBitmap.SetPixel(x - startXValue, y - startYValue, color); } } selectedBitmap.Save(memoryStream, imageFormat); @@ -166,7 +192,7 @@ public class ProcessData : IProcessData fileInfoCollection.Add(new FileInfo(saveFileName)); SaveToFile(extension, saveFileName, memoryStream); } - return new(colors.ToArray(), endX - startX, endY - startY); + return new(colors.ToArray(), endXValue - startXValue, endYValue - startYValue); } private static string Get(IFileRead fileRead, string extension, string extra) @@ -212,20 +238,20 @@ public class ProcessData : IProcessData File.WriteAllLines(textFileName, lines); } - internal static List<(string, Size, Color[])> GetColorCollections(int startX, int startY, int endX, int endY, string masterImageDirectory) + internal static List<(string, Size, Color[])> GetColorCollections(int startX, int startY, int endX, int endY, int offSetX, int offSetY, string masterImageDirectory) { List<(string, Size, Color[])> results = new(); (Size Size, Color[] Colors) result; string[] files = Directory.GetFiles(masterImageDirectory, "*.jpeg", SearchOption.TopDirectoryOnly); foreach (string file in files) { - result = Get(file, startX, startY, endX, endY); + result = Get(file, startX, startY, endX, endY, offSetX, offSetY); results.Add(new(file, result.Size, result.Colors)); } return results; } - private void Parse(IFileRead fileRead, List fileInfoCollection, int startX, int startY, int endX, int endY, Size size, List> colorCollections) + private void Parse(IFileRead fileRead, List fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, Size size, List> colorCollections) { Red = 0; Green = 0; @@ -235,7 +261,7 @@ public class ProcessData : IProcessData const int thresHold = 70; const string extension = ".tiff"; List<(string File, int TotalDelta)> totalDeltaCollection = new(); - (Color[] sourceColors, int width, int height) = Get(fileRead, fileInfoCollection, startX, startY, endX, endY, extension, size); + (Color[] sourceColors, int width, int height) = Get(fileRead, fileInfoCollection, startX, startY, endX, endY, offSetX, offSetY, extension, size); foreach ((string file, Color[] colors) in colorCollections) { totalDelta = 0; diff --git a/Adaptation/_Tests/Shared/AdaptationTesting.cs b/Adaptation/_Tests/Shared/AdaptationTesting.cs index 7e7c8cc..691f3fa 100644 --- a/Adaptation/_Tests/Shared/AdaptationTesting.cs +++ b/Adaptation/_Tests/Shared/AdaptationTesting.cs @@ -897,6 +897,15 @@ public class AdaptationTesting : ISMTP return results; } + public (string i, string v, string c, string n, int p, string f) GetCellInstanceVersionCore(string testName) + { + (string, string, string, string, int, string) results; + MethodBaseName mbn = GetMethodBaseName(_DummyRoot, _Environment, _HasWaitForProperty, testName, @"D:\Tmp\Phares"); + Tuple cellInstanceVersionTuple = GetCellInstanceVersionTuple(mbn.CellInstanceName, mbn.CellInstanceVersionName); + results = new(mbn.CellInstanceName, mbn.CellInstanceVersionName, cellInstanceVersionTuple.Item2.CellCommunicatingRule, cellInstanceVersionTuple.Item2.CellNotCommunicatingRule, cellInstanceVersionTuple.Item2.EdaConnection.PortNumber, cellInstanceVersionTuple.Item2.FrozenBy); + return results; + } + public string[] GetCSharpText(string testName) { string[] results; diff --git a/Adaptation/_Tests/Static/EAF.cs b/Adaptation/_Tests/Static/EAF.cs new file mode 100644 index 0000000..76ae743 --- /dev/null +++ b/Adaptation/_Tests/Static/EAF.cs @@ -0,0 +1,190 @@ +using Adaptation._Tests.Shared; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.Linq; +using System.Net.Http; +using System.Reflection; +using System.Threading.Tasks; + +namespace Adaptation._Tests.Static; + +[TestClass] +public class EAF : LoggingUnitTesting, IDisposable +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + internal static EAF LoggingUnitTesting { get; private set; } + + internal static AdaptationTesting AdaptationTesting { get; private set; } + + public EAF() : base(testContext: null, declaringType: null) + { + if (LoggingUnitTesting is null) + throw new Exception(); + } + + public EAF(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType) + { } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + if (LoggingUnitTesting is null) + LoggingUnitTesting = new EAF(testContext); + string dummyRoot = string.Empty; + bool skipEquipmentDictionary = true; + AdaptationTesting = new(dummyRoot, testContext, skipEquipmentDictionary, LoggingUnitTesting.TestContextPropertiesAsJson, LoggingUnitTesting.HasWaitForProperty); + } + + [ClassCleanup()] + public static void ClassCleanup() + { + if (LoggingUnitTesting.Logger is not null) + LoggingUnitTesting.Logger.LogInformation("Cleanup"); + if (LoggingUnitTesting is not null) + LoggingUnitTesting.Dispose(); + } + + [TestMethod] + public void Staging() + { + string testName; + Task task; + string[] segments; + HttpClient httpClient = new(); + MethodBase methodBase = new StackFrame().GetMethod(); + string currentActiveVersionTag = "CurrentActiveVersion>"; + string managementSite = "http://mestsa07ec.ec.local:9003/CellInstances/entity/"; + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + string[] cellInstances = new string[] { "R74-PLC", "MET08THFTIRQS408M", "HGCV1", "TENCOR1", "R53-EQPT", "EC", "TENCOR1-EDA", "R47-PLC-EDA", "SPV01", "CDE4-EDA", "MET08DDUPSP1TBI", "BACKLOG", "R34", "BIORAD5", "CDE3-EQPT", "BIORAD4-EDA", "CDE2-EDA", "CDE5-EDA", "DEP08SIHTRPLC", "R70-PLC-EDA", "MET08THFTIRSTRATUS", "R34-EQPT", "MET08ANLYSDIFAAST230", "BIORAD4", "CDE3-EDA", "CDE5-EQPT", "R72-PLC-EDA", "R74-PLC-EDA", "BACKLOG-EQPT", "CDE3", "TENCOR3-EDA", "R73-PLC-EDA", "R47-PLC", "SP101", "SPV01-EDA", "BIORAD3-EDA", "R70-PLC", "MET08RESIHGCV", "CDE4", "MET08RESIMAPCDE", "TENCOR2", "TENCOR3", "DEP08SIASM", "SP101-EQPT", "BIORAD2", "CDE2", "HGCV3-EDA", "HGCV2-EDA", "HGCV1-EDA", "BIORAD2-EDA", "TENCOR2-EDA", "CDE4-EQPT", "R72-PLC", "HGCV3", "HGCV2", "BIORAD3", "BIORAD5-EDA", "R34-EDA", "SP101-EDA", "R73-PLC", "CDE5", "MET08DDUPSFS6420" }; + foreach (string cellInstance in cellInstances.OrderBy(l => l)) + { + if (!cellInstance.Contains('-')) + continue; + task = httpClient.GetStringAsync($"{managementSite}{cellInstance}"); + task.Wait(); + if (task.Result is not string response) + continue; + segments = response.Split(currentActiveVersionTag); + if (segments.Length < 2) + continue; + testName = string.Concat("Staging__v", segments[1].Split('<')[0].Replace('.', '_'), "__", cellInstance.Replace('-', '_'), "__"); + (string i, string v, string c, string n, int p, string f) = AdaptationTesting.GetCellInstanceVersionCore(testName); + LoggingUnitTesting.Logger.LogInformation($"{p},{v},{i},{c},{n},{f}"); + } + Assert.IsTrue(true); + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + +} + +// 553,v2.19.0,R47-PLC-EDA,,,messtec102.EC.local +// 553,v2.19.0,R47-PLC,,,messtec102.EC.local +// 7589,v2.43.3,CDE5-EQPT,DownloadRsMFile.Communicating,DownloadRsMFile.NotCommunicating,messtec102.EC.local +// 8034,v2.43.4,R34-EQPT,DownloadJpegFile.Communicating,DownloadJpegFile.NotCommunicating, +// 8034,v2.43.4,R53-EQPT,DownloadJpegFile.Communicating,DownloadJpegFile.NotCommunicating, +// 8134,v2.43.4,R34,jpeg.Communicating,jpeg.NotCommunicating, +// 8134,v4.15.0,R34-EDA,,,messtec102.EC.local +// 8409,v2.43.0,MET08ANLYSDIFAAST230,MoveMatchingFiles.Communicating,MoveMatchingFiles.NotCommunicating,messtec102.EC.local +// 8439,v2.43.1,EC,,,messtec102.EC.local +// 8500,v2.43.0,BIORAD2,QS408M.Communicating,QS408M.NotCommunicating,messtec102.EC.local +// 8500,v4.15.0,BIORAD2-EDA,,,messtec102.EC.local +// 8501,v2.43.0,BIORAD3,QS408M.Communicating,QS408M.NotCommunicating,messtec102.EC.local +// 8501,v4.15.0,BIORAD3-EDA,,,messtec102.EC.local +// 8509,v2.43.2,MET08THFTIRQS408M,MoveMatchingFiles.Communicating,MoveMatchingFiles.NotCommunicating,messtec102.EC.local +// 8510,v2.43.0,BIORAD4,QS408M.Communicating,QS408M.NotCommunicating,messtec102.EC.local +// 8510,v4.15.0,BIORAD4-EDA,,,messtec102.EC.local +// 8511,v2.43.0,BIORAD5,QS408M.Communicating,QS408M.NotCommunicating,messtec102.EC.local +// 8511,v4.15.0,BIORAD5-EDA,,,messtec102.EC.local +// 8519,v2.43.2,MET08THFTIRSTRATUS,MoveMatchingFiles.Communicating,MoveMatchingFiles.NotCommunicating,messtec102.EC.local +// 8520,v2.43.4,CDE2,txt.Communicating,txt.NotCommunicating,MESSA010EC.EC.local +// 8520,v4.15.0,CDE2-EDA,,,messtec102.EC.local +// 8521,v2.43.4,CDE5,RsM.Communicating,RsM.NotCommunicating,MESSA010EC.EC.local +// 8521,v4.15.0,CDE5-EDA,,,messtec102.EC.local +// 8524,v2.43.0,BACKLOG,json.Communicating,json.NotCommunicating, +// 8524,v2.43.4,CDE3,RsM.Communicating,RsM.NotCommunicating,MESSA010EC.EC.local +// 8524,v2.43.4,CDE4,RsM.Communicating,RsM.NotCommunicating,MESSA010EC.EC.local +// 8524,v4.15.0,CDE3-EDA,,,messtec102.EC.local +// 8524,v4.15.0,CDE4-EDA,,,messtec102.EC.local +// 8526,v2.43.0,CDE3-EQPT,DownloadRsMFile.Communicating,DownloadRsMFile.NotCommunicating,messtec102.EC.local +// 8526,v2.43.3,CDE4-EQPT,DownloadRsMFile.Communicating,DownloadRsMFile.NotCommunicating, +// 8528,v2.43.0,BACKLOG-EQPT,ConvertExcelToJson.Communicating,ConvertExcelToJson.NotCommunicating, +// 8529,v2.43.4,MET08RESIMAPCDE,MoveMatchingFiles.Communicating,MoveMatchingFiles.NotCommunicating, +// 8530,v2.43.4,HGCV1,pcl.Communicating,pcl.NotCommunicating,MESSA010EC.EC.local +// 8530,v4.15.0,HGCV1-EDA,,,messtec102.EC.local +// 8531,v2.43.4,HGCV2,pcl.Communicating,pcl.NotCommunicating,MESSA010EC.EC.local +// 8531,v4.15.0,HGCV2-EDA,,,messtec102.EC.local +// 8532,v2.43.4,HGCV3,pcl.Communicating,pcl.NotCommunicating,MESSA010EC.EC.local +// 8532,v4.15.0,HGCV3-EDA,,,messtec102.EC.local +// 8537,v2.43.4,DEP08SIASM,MonitorApplication.Communicating,MonitorApplication.NotCommunicating, +// 8538,v2.43.0,DEP08SIHTRPLC,ZipFilesByDate.Communicating,ZipFilesByDate.NotCommunicating, +// 8539,v2.43.4,MET08RESIHGCV,MoveMatchingFiles.Communicating,MoveMatchingFiles.NotCommunicating,MESSA010EC.EC.local +// 8540,v2.43.4,TENCOR1,pcl.Communicating,pcl.NotCommunicating,MESSA010EC.EC.local +// 8540,v4.15.0,TENCOR1-EDA,,,messtec102.EC.local +// 8541,v2.43.4,TENCOR2,pcl.Communicating,pcl.NotCommunicating,MESSA010EC.EC.local +// 8541,v4.15.0,TENCOR2-EDA,,,messtec102.EC.local +// 8542,v2.43.4,TENCOR3,pcl.Communicating,pcl.NotCommunicating +// 8542,v4.15.0,TENCOR3-EDA,,,messtec102.EC.local +// 8549,v2.43.4,MET08DDUPSFS6420,MoveMatchingFiles.Communicating,MoveMatchingFiles.NotCommunicating, +// 8550,v4.15.0,SP101-EDA,,,messtec102.EC.local +// 8551,v2.43.4,SP101,txt.Communicating,txt.NotCommunicating,MESSA010EC.EC.local +// 8555,v2.43.0,SP101-EQPT,MoveAllFiles.Communicating,MoveAllFiles.NotCommunicating,messtec102.EC.local +// 8559,v2.43.4,MET08DDUPSP1TBI,MoveMatchingFiles.Communicating,MoveMatchingFiles.NotCommunicating,MESSA010EC.EC.local +// 8569,v2.43.0,SPV01,,,messtec102.EC.local +// 8569,v4.15.0,SPV01-EDA,,,messtec102.EC.local +// 8770,v1.0.1,R70-PLC-EDA,,,messtec102.EC.local +// 8770,v2.19.0,R70-PLC,,,messtec102.EC.local +// 8772,v1.0.1,R72-PLC-EDA,,,messtec102.EC.local +// 8772,v2.19.0,R72-PLC,,,messtec102.EC.local +// 8773,v1.0.1,R73-PLC-EDA,,,messtec102.EC.local +// 8773,v2.19.0,R73-PLC,,,messtec102.EC.local +// 8774,v1.0.1,R74-PLC-EDA,,,messtec102.EC.local +// 8774,v2.19.0,R74-PLC,,,messtec102.EC.local + +// p p v i +// 553 553 v2.19.0 R47-PLC +// 7589 7589 v2.43.3 CDE5-EQPT +// 8034 8034 v2.43.4 R34-EQPT +// 8034 +// 8134 8134 v2.43.4 R34 +// 8409 8409 v2.43.0 MET08ANLYSDIFAAST230 +// 8439 8439 v2.43.1 EC +// 8500 8500 v2.43.0 BIORAD2 +// 8501 8501 v2.43.0 BIORAD3 +// 8509 8509 v2.43.2 MET08THFTIRQS408M +// 8510 8510 v2.43.0 BIORAD4 +// 8511 8511 v2.43.0 BIORAD5 +// 8519 8519 v2.43.2 MET08THFTIRSTRATUS +// 8520 8520 v2.43.4 CDE2 +// 8521 8521 v2.43.4 CDE5 +// 8524 +// 8524 8524 v2.43.4 CDE3 +// 8524 v2.43.4 CDE4 +// 8526 8526 v2.43.0 CDE3-EQPT +// 8526 v2.43.3 CDE4-EQPT +// 8528 8528 v2.43.0 BACKLOG-EQPT +// 8529 8529 v2.43.4 MET08RESIMAPCDE +// 8530 8530 v2.43.4 HGCV1 +// 8531 8531 v2.43.4 HGCV2 +// 8532 8532 v2.43.4 HGCV3 +// 8537 8537 v2.43.4 DEP08SIASM +// 8538 8538 v2.43.0 DEP08SIHTRPLC +// 8539 8539 v2.43.4 MET08RESIHGCV +// 8540 8540 v2.43.4 TENCOR1 +// 8541 8541 v2.43.4 TENCOR2 +// 8542 8542 v2.43.4 TENCOR3 +// 8549 8549 v2.43.4 MET08DDUPSFS6420 +// 8551 8551 v2.43.4 SP101 +// 8555 8555 v2.43.0 SP101-EQPT +// 8559 8559 v2.43.4 MET08DDUPSP1TBI +// 8569 8569 v2.43.0 SPV01 +// 8770 8770 v2.19.0 R70-PLC +// 8772 8772 v2.19.0 R72-PLC +// 8773 8773 v2.19.0 R73-PLC +// 8774 8774 v2.19.0 R74-PLC +// 8775 v2.43.0 BACKLOG +// 8653 v2.43.4 R53-EQPT diff --git a/Adaptation/_Tests/Static/xml.cs b/Adaptation/_Tests/Static/xml.cs new file mode 100644 index 0000000..05bfa9f --- /dev/null +++ b/Adaptation/_Tests/Static/xml.cs @@ -0,0 +1,74 @@ +using Adaptation._Tests.Shared; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.Reflection; +using System.Text; + +namespace Adaptation._Tests.Static; + +[TestClass] +public class XML : LoggingUnitTesting, IDisposable +{ + +#pragma warning disable CA2254 +#pragma warning disable IDE0060 + + internal static XML LoggingUnitTesting { get; private set; } + + public XML() : base(testContext: null, declaringType: null) + { + if (LoggingUnitTesting is null) + throw new Exception(); + } + + public XML(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType) + { } + + [ClassInitialize] + public static void ClassInitialize(TestContext testContext) + { + if (LoggingUnitTesting is null) + LoggingUnitTesting = new XML(testContext); + } + + [ClassCleanup()] + public static void ClassCleanup() + { + if (LoggingUnitTesting.Logger is not null) + LoggingUnitTesting.Logger.LogInformation("Cleanup"); + if (LoggingUnitTesting is not null) + LoggingUnitTesting.Dispose(); + } + + [TestMethod] + public void TestXmlBuild() + { + MethodBase methodBase = new StackFrame().GetMethod(); + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); + string key; + string value; + int counter = 500; + StringBuilder stringBuilder = new(); + string a = "0CellInstance.R"; + string f = ""; + string h = "String"; + int[] reactors = new int[] { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 70, 72, 73, 74, 75, 77, 79 }; + foreach (int reactor in reactors) + { + for (int i = 1; i < 4; i++) + { + counter += 1; + key = i switch { 1 => ".Alias", 2 => "-EQPT.Alias", 3 => "-EQPT.StaticFileServer", _ => throw new Exception() }; + value = i switch { 1 or 2 => $"R{reactor}", 3 => "10.95.154.##", _ => throw new Exception() }; + _ = stringBuilder.Append(a).Append(counter).Append(c).Append(reactor).Append(key).Append(f).Append(value).AppendLine(h); + } + } + System.IO.File.WriteAllText(@"D:\Tmp\Phares\a.xml", stringBuilder.ToString()); + Assert.IsTrue(true); + LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); + } + +} \ No newline at end of file