using Adaptation._Tests.Shared; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Text; namespace Adaptation._Tests.Static; [TestClass] public class WC : LoggingUnitTesting, IDisposable { #pragma warning disable CA2254 #pragma warning disable IDE0060 internal static WC LoggingUnitTesting { get; private set; } public WC() : base(testContext: null, declaringType: null) { if (LoggingUnitTesting is null) throw new Exception(); } public WC(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType) { } [ClassInitialize] public static void ClassInitialize(TestContext testContext) => LoggingUnitTesting ??= new WC(testContext); [ClassCleanup()] public static void ClassCleanup() { LoggingUnitTesting?.Logger?.LogInformation("Cleanup"); LoggingUnitTesting?.Dispose(); } private static void NonThrowTryCatch() { try { throw new Exception(); } catch (Exception) { } } [TestMethod] public void TestDateTime() { DateTime dateTime = DateTime.Now; Assert.IsTrue(dateTime.ToString("M/d/yyyy h:mm:ss tt") == dateTime.ToString()); } #if DEBUG [Ignore] #endif [TestMethod] public void Development() { MethodBase methodBase = new StackFrame().GetMethod(); StringBuilder results = new(); (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] { new("WC6INCH1-EQPT", "v2.56.0"), new("WC6INCH2-EQPT", "v2.56.0"), new("WC6INCH3-EQPT", "v2.56.0"), new("WC6INCH4-EQPT", "v2.56.0"), new("WC8INCH1-EQPT", "v2.56.0"), new("WC8INCH2-EQPT", "v2.56.0"), new("WC8INCH3-EQPT", "v2.56.0"), }; string development = "http://eaf-dev.mes.infineon.com:9003/CellInstanceServiceV2"; Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); foreach ((string cellInstanceName, string cellInstanceVersionName) in collection) { cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{development}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); } string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; if (!Directory.Exists(sourceDirectory)) _ = Directory.CreateDirectory(sourceDirectory); File.WriteAllText(Path.Combine(sourceDirectory, $"{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv"), results.ToString()); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); NonThrowTryCatch(); } #if DEBUG [Ignore] #endif [TestMethod] public void Staging() { MethodBase methodBase = new StackFrame().GetMethod(); StringBuilder results = new(); (string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[] { new("WC6INCH1-EQPT", "v2.56.0"), new("WC6INCH2-EQPT", "v2.56.0"), new("WC6INCH3-EQPT", "v2.56.0"), new("WC6INCH4-EQPT", "v2.56.0"), new("WC8INCH1-EQPT", "v2.56.0"), new("WC8INCH2-EQPT", "v2.56.0"), new("WC8INCH3-EQPT", "v2.56.0"), }; string staging = "http://mestsa07ec.infineon.com:9003/CellInstanceServiceV2"; Shared.PasteSpecialXml.EAF.XML.API.CellInstance.CellInstanceVersion cellInstanceVersion; LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); foreach ((string cellInstanceName, string cellInstanceVersionName) in collection) { cellInstanceVersion = AdaptationTesting.GetCellInstanceVersion($"{staging}/{cellInstanceName}/{cellInstanceVersionName}/configuration"); _ = results.AppendLine($"{cellInstanceName}\t{cellInstanceVersionName}\t{cellInstanceVersion.EdaConnection.PortNumber}"); } string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; if (!Directory.Exists(sourceDirectory)) _ = Directory.CreateDirectory(sourceDirectory); File.WriteAllText(Path.Combine(sourceDirectory, $"{methodBase.Module.Name}-{methodBase.ReflectedType.Name}-{methodBase.Name}.tsv"), results.ToString()); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); NonThrowTryCatch(); } [TestMethod] public void TestSlotMaps() { MethodBase methodBase = new StackFrame().GetMethod(); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T00", "P0000000", "0000000000000000000000000"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T25", "P1FFFFFF", "1111111111111111111111111"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T12", "P0AAAAAA", "0101010101010101010101010"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T13", "P1555555", "1010101010101010101010101"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T20", "P0EFFFF8", "0111011111111111111111000"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T20", "P07FFFF8", "0011111111111111111111000"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T20", "P17FFFF0", "1011111111111111111110000"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T03", "P1002002", "1000000000010000000000010"); FileHandlers.wc.WaferCounterHelper.TestSlotMap("T02", "P1000002", "1000000000000000000000010"); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); NonThrowTryCatch(); } [TestMethod] public void CellInstanceVersionEdaConnectionPortNumber() { MethodBase methodBase = new StackFrame().GetMethod(); string sourceDirectory = "D:/Tmp/cellInstanceVersion.EdaConnection.PortNumber"; if (Directory.Exists(sourceDirectory)) { string destinationDirectory = Path.Combine(sourceDirectory, "All"); if (!Directory.Exists(destinationDirectory)) _ = Directory.CreateDirectory(destinationDirectory); List lines = new(); string[] files = Directory.GetFiles(sourceDirectory, "*.tsv", SearchOption.TopDirectoryOnly); foreach (string file in files) lines.AddRange(File.ReadAllLines(file)); File.WriteAllLines(Path.Combine(destinationDirectory, $"{DateTime.Now.Ticks}.tsv"), lines.Distinct().OrderBy(l => l)); } LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); NonThrowTryCatch(); } }