R53 and R55

This commit is contained in:
Mike Phares 2022-09-29 18:20:21 -07:00
parent e68df9c672
commit c1d2b619ee
5 changed files with 319 additions and 17 deletions

View File

@ -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<int> _PreviousTotalDeltaCollection;
protected readonly Dictionary<string, string> _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];

View File

@ -30,7 +30,7 @@ public class ProcessData : IProcessData
List<object> Shared.Properties.IProcessData.Details => _Details;
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, Size size, List<Tuple<string, Color[]>> colorCollections)
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, Size size, List<Tuple<string, Color[]>> colorCollections)
{
if (logistics is null)
{ }
@ -39,7 +39,25 @@ public class ProcessData : IProcessData
_Details = new List<object>();
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<Color> 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<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, string extension, Size size)
private static (Color[], int, int) Get(IFileRead fileRead, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, string extension, Size size)
{
Color color;
List<Color> 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 <http://10.95.154.28/set_output?input=0&output=0&venc_framerate=60&venc_gop=300&venc_width=640&venc_height=480&venc_bitrate=32000&http_ts_uri=/0.ts&http_flv_uri=/0.flv&rtsp_uri=/0&rtmp_enable=0&rtmp_uri=/0&rtmp_publish_uri=rtmp%3A%2F%2F192.168.1.169%2Flive%2F0&rtmp_publish_enable=0&http_ts_enable=1&http_flv_enable=1&rtsp_enable=1&venc_profile=0&http_hls_uri=/0.m3u8&http_hls_enable=0&venc_width_height_same_as_input=0&multicast_ip=238.0.0.1&multicast_port=1234&multicast_enable=0&venc_codec=265&srt_enable=0&srt_port=9000&srt_publish_enable=0&srt_publish_uri=srt%3A%2F%2F192.168.1.169%3A9000&srt_key=0123456789&srt_key_enable=0&max_qp=42&venc_rc_mode=0&ts_muxrate=0&_=1655307485097>");
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<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, Size size, List<Tuple<string, Color[]>> colorCollections)
private void Parse(IFileRead fileRead, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, Size size, List<Tuple<string, Color[]>> 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;

View File

@ -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<string, CellInstanceVersion> 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;

View File

@ -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<string> 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

View File

@ -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 = "<d2p1:ModelObjectParameterDefinition z:Id=\"i";
string c = "\"><d2p1:EnumType></d2p1:EnumType><d2p1:Id>0</d2p1:Id><d2p1:Name>CellInstance.R";
string f = "</d2p1:Name><d2p1:Value>";
string h = "</d2p1:Value><d2p1:ValueType>String</d2p1:ValueType></d2p1:ModelObjectParameterDefinition>";
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"));
}
}