using Adaptation._Tests.Shared; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Diagnostics; using System.Reflection; namespace Adaptation._Tests.Static; [TestClass] public class QS408M : LoggingUnitTesting, IDisposable { #pragma warning disable CA2254 #pragma warning disable IDE0060 internal static QS408M LoggingUnitTesting { get; private set; } public QS408M() : base(testContext: null, declaringType: null) { if (LoggingUnitTesting is null) throw new Exception(); } public QS408M(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType) { } [ClassInitialize] public static void ClassInitialize(TestContext testContext) { if (LoggingUnitTesting is null) LoggingUnitTesting = new QS408M(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 TestDescriptor() { FileHandlers.QS408M.Descriptor descriptor; MethodBase methodBase = new StackFrame().GetMethod(); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration")); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor(string.Empty); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Reactor)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("12-123456-1234"); Assert.IsTrue(descriptor.Reactor is "12"); Assert.IsTrue(descriptor.RDS is "123456"); Assert.IsTrue(descriptor.PSN is "1234"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("123456"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Reactor)); Assert.IsTrue(descriptor.RDS is "123456"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("1T123456"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Reactor)); Assert.IsTrue(descriptor.RDS is "123456"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("MP"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Reactor)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); Assert.IsTrue(descriptor.Employee is "MP"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("12-123456-1234.2-1"); Assert.IsTrue(descriptor.Reactor is "12"); Assert.IsTrue(descriptor.RDS is "123456"); Assert.IsTrue(descriptor.PSN is "1234"); Assert.IsTrue(descriptor.Layer is "2"); Assert.IsTrue(descriptor.Zone is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("12-123456-1234.02-1"); Assert.IsTrue(descriptor.Reactor is "12"); Assert.IsTrue(descriptor.RDS is "123456"); Assert.IsTrue(descriptor.PSN is "1234"); Assert.IsTrue(descriptor.Layer is "2"); Assert.IsTrue(descriptor.Zone is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("20"); Assert.IsTrue(descriptor.Reactor is "20"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Layer)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("20.2"); Assert.IsTrue(descriptor.Reactor is "20"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); Assert.IsTrue(descriptor.Layer is "2"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Zone)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("20.2.1"); Assert.IsTrue(descriptor.Layer is "2"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(descriptor.Reactor is "20"); Assert.IsTrue(descriptor.Zone is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); descriptor = FileHandlers.QS408M.ProcessData.GetDescriptor("20.1.1"); Assert.IsTrue(descriptor.Layer is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.PSN)); Assert.IsTrue(string.IsNullOrEmpty(descriptor.RDS)); Assert.IsTrue(descriptor.Reactor is "20"); Assert.IsTrue(descriptor.Zone is "1"); Assert.IsTrue(string.IsNullOrEmpty(descriptor.Employee)); LoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit")); } }