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")); } }