AdaptationTesting

This commit is contained in:
Mike Phares 2022-02-22 14:03:23 -07:00
parent a8a93cb115
commit 99c6474146
5 changed files with 84 additions and 66 deletions

View File

@ -1,9 +1,11 @@
{
"cSpell.words": [
"CICN",
"DDUPSFS",
"EQPT",
"gpcl",
"IKVM",
"ipdsf",
"ISMTP",
"JOBID",
"Linc",
@ -13,10 +15,12 @@
"PDFC",
"pdmodel",
"pdsf",
"pdsfc",
"PPTST",
"RESIMAPTENCOR",
"TENCOR",
"TIBCO"
"TIBCO",
"Villach"
],
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#7933a3",

View File

@ -112,7 +112,7 @@ public class FileRead : Properties.IFileRead
// throw new Exception(cellInstanceConnectionName);
}
ModelObjectParameterDefinition[] paths = GetProperties(cellInstanceConnectionName, modelObjectParameters, "Path.");
if (paths.Length < 4)
if (paths.Length < 3)
throw new Exception(cellInstanceConnectionName);
if (isDuplicator)
_MesEntity = string.Empty;

View File

@ -3,9 +3,12 @@ using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shared;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text.Json;
using System.Threading;
namespace _Tests.CreateSelfDescription.Staging.v2_39_0;
@ -71,7 +74,7 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420__()
{
string check = "~IsXToOpenInsight";
string check = "~IsXToIQSGaN";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
@ -81,7 +84,7 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420___()
{
string check = "~IsXToOpenInsightMetrologyViewerAttachments";
string check = "~IsXToOpenInsight";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
@ -91,7 +94,7 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420____()
{
string check = "~IsXToAPC";
string check = "~IsXToOpenInsightMetrologyViewerAttachments";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
@ -101,7 +104,7 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420_____()
{
string check = "~IsXToSPaCe";
string check = "~IsXToAPC";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
@ -111,7 +114,7 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420______()
{
string check = "~IsXToArchive";
string check = "~IsXToSPaCe";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
@ -121,7 +124,7 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420_______()
{
string check = "~IsArchive";
string check = "~IsXToArchive";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
@ -130,6 +133,16 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420________()
{
string check = "~IsArchive";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420_________()
{
string check = "~IsDummy";
MethodBase methodBase = new StackFrame().GetMethod();
@ -138,4 +151,14 @@ public class MET08DDUPSFS6420 : EAFLoggingUnitTesting
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420__________()
{
string check = "~IsManualOIEntry";
MethodBase methodBase = new StackFrame().GetMethod();
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Getting configuration"));
_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);
EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, " - Exit"));
}
}

View File

@ -65,4 +65,10 @@ public class MET08DDUPSFS6420
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420________() => _MET08DDUPSFS6420.Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420________();
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420_________() => _MET08DDUPSFS6420.Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420_________();
[TestMethod]
public void Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420__________() => _MET08DDUPSFS6420.Staging__v2_39_0__MET08DDUPSFS6420__MET08DDUPSFS6420__________();
}

View File

@ -432,12 +432,6 @@ public class AdaptationTesting : ISMTP
loopName = "CreateSelfDescription";
else
throw new Exception();
if (i == 2)
_ = stringBuilder.
AppendLine("using Microsoft.VisualStudio.TestTools.UnitTesting;").
AppendLine("using Shared;").
AppendLine("using System.Diagnostics;");
else if (i == 1)
_ = stringBuilder.
AppendLine("using Adaptation.Shared.Methods;").
AppendLine("using Microsoft.Extensions.Logging;").
@ -450,11 +444,8 @@ public class AdaptationTesting : ISMTP
AppendLine("using System.Reflection;").
AppendLine("using System.Text.Json;").
AppendLine("using System.Threading;");
else
throw new Exception();
_ = stringBuilder.AppendLine().
Append("namespace _Tests.").Append(loopName).Append('.').Append(_Environment).Append('.').AppendLine(cellInstanceVersionNameAsCode).
AppendLine("{").
Append("namespace _Tests.").Append(loopName).Append('.').Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).AppendLine(";").
AppendLine().
AppendLine("[TestClass]");
if (i == 2)
@ -462,14 +453,19 @@ public class AdaptationTesting : ISMTP
Append("public class ").AppendLine(cellInstanceNameWithoutHyphen).
AppendLine("{").
AppendLine().
AppendLine("#pragma warning disable CA2254").
AppendLine("#pragma warning disable IDE0060").
AppendLine().
Append("private static CreateSelfDescription.").Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append('.').Append(cellInstanceNameWithoutHyphen).Append(" _").Append(cellInstanceNameWithoutHyphen).AppendLine(";");
else if (i == 1)
_ = stringBuilder.
Append("public class ").Append(cellInstanceNameWithoutHyphen).AppendLine(" : EAFLoggingUnitTesting").
AppendLine("{").
AppendLine().
Append("private static ").Append(cellInstanceNameWithoutHyphen).AppendLine(" _EAFLoggingUnitTesting;").
Append("internal static ").Append(cellInstanceNameWithoutHyphen).AppendLine(" EAFLoggingUnitTesting => _EAFLoggingUnitTesting;");
AppendLine("#pragma warning disable CA2254").
AppendLine("#pragma warning disable IDE0060").
AppendLine().
Append("internal static ").Append(cellInstanceNameWithoutHyphen).AppendLine(" EAFLoggingUnitTesting { get; private set; }");
else
throw new Exception();
if (i == 2)
@ -479,7 +475,7 @@ public class AdaptationTesting : ISMTP
AppendLine().
Append("public ").Append(cellInstanceNameWithoutHyphen).AppendLine("() : base(testContext: null, declaringType: null, skipEquipmentDictionary: false)").
AppendLine("{").
AppendLine("if (_EAFLoggingUnitTesting is null)").
AppendLine("if (EAFLoggingUnitTesting is null)").
AppendLine("throw new Exception();").
AppendLine("}").
AppendLine().
@ -500,10 +496,10 @@ public class AdaptationTesting : ISMTP
AppendLine("}");
else if (i == 1)
_ = stringBuilder.
AppendLine("if (_EAFLoggingUnitTesting is null)").
Append("_EAFLoggingUnitTesting = new ").Append(cellInstanceNameWithoutHyphen).AppendLine("(testContext);").
AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, \" - ClassInitialize\"));").
AppendLine("string[] fileNameAndText = _EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);").
AppendLine("if (EAFLoggingUnitTesting is null)").
Append("EAFLoggingUnitTesting = new ").Append(cellInstanceNameWithoutHyphen).AppendLine("(testContext);").
AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, \" - ClassInitialize\"));").
AppendLine("string[] fileNameAndText = EAFLoggingUnitTesting.AdaptationTesting.GetCSharpText(testContext.TestName);").
AppendLine("File.WriteAllText(fileNameAndText[0], fileNameAndText[1]);").
AppendLine("File.WriteAllText(fileNameAndText[2], fileNameAndText[3]);").
AppendLine("}");
@ -517,10 +513,10 @@ public class AdaptationTesting : ISMTP
AppendLine("[ClassCleanup()]").
AppendLine("public static void ClassCleanup()").
AppendLine("{").
AppendLine("if (!(_EAFLoggingUnitTesting.Logger is null))").
AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(\"Cleanup\");").
AppendLine("if (!(_EAFLoggingUnitTesting is null))").
AppendLine("_EAFLoggingUnitTesting.Dispose();").
AppendLine("if (EAFLoggingUnitTesting.Logger is not null)").
AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(\"Cleanup\");").
AppendLine("if (EAFLoggingUnitTesting is not null)").
AppendLine("EAFLoggingUnitTesting.Dispose();").
AppendLine("}").
AppendLine();
else
@ -541,46 +537,35 @@ public class AdaptationTesting : ISMTP
check = (from l in componentsCellComponentCellComponent.Equipment.ConnectionSettings.Setting where l.Name == sourceDirectoryCloaking select l.Value).FirstOrDefault();
if (string.IsNullOrEmpty(check))
check = componentsCellComponentCellComponent.Equipment.SourceFileFilter;
if (i == 2)
{
_ = stringBuilder.
AppendLine("[TestMethod]").
Append("public void ").Append(methodName).AppendLine("()").
AppendLine("{");
if (i == 2)
_ = stringBuilder.Append('_').Append(cellInstanceNameWithoutHyphen).Append('.').Append(methodName).AppendLine("();");
Append("public void ").Append(methodName).Append("() => ").Append('_').Append(cellInstanceNameWithoutHyphen).Append('.').Append(methodName).AppendLine("();");
}
else if (i == 1)
{
if (componentsCellComponentCellComponent.Equipment.EquipmentType.Version != cellInstanceVersionName)
throw new Exception("Versions should match!");
equipmentTypeName = componentsCellComponentCellComponent.Equipment.EquipmentType.Name;
_ = stringBuilder.
AppendLine("[TestMethod]").
Append("public void ").Append(methodName).AppendLine("()").
AppendLine("{").
Append("string check = \"").Append(check.Split('\\').Last()).AppendLine("\";").
AppendLine("MethodBase methodBase = new StackFrame().GetMethod();").
AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Getting configuration\"));").
AppendLine("string[] fileNameAndJson = _EAFLoggingUnitTesting.AdaptationTesting.GetConfiguration(methodBase);").
AppendLine("Assert.IsTrue(fileNameAndJson[1].Contains(check));").
AppendLine("File.WriteAllText(fileNameAndJson[0], fileNameAndJson[1]);");
if (componentsCellComponentCellComponent.Equipment.EquipmentType.Name == componentsCellComponentCellComponentEquipmentTypeNames[0])
_ = stringBuilder.
AppendLine("IFileRead fileRead = _EAFLoggingUnitTesting.AdaptationTesting.Get(methodBase, sourceFileLocation: string.Empty, sourceFileFilter: string.Empty, useCyclicalForDescription: false);").
AppendLine("Assert.IsFalse(string.IsNullOrEmpty(fileRead.CellInstanceConnectionName));");
_ = stringBuilder.
AppendLine("_EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Exit\"));");
}
else
throw new Exception();
_ = stringBuilder.
AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Getting configuration\"));").
AppendLine("_ = Helpers.Metrology.GetWriteConfigurationGetFileRead(methodBase, check, EAFLoggingUnitTesting.AdaptationTesting);").
AppendLine("EAFLoggingUnitTesting.Logger.LogInformation(string.Concat(methodBase.Name, \" - Exit\"));").
AppendLine("}").
AppendLine();
}
else
throw new Exception();
}
_ = stringBuilder.
AppendLine("}").
AppendLine().
AppendLine("}").
AppendLine().
AppendLine("// dotnet build --runtime win-x64").
Append("// dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~_Tests.").Append(loopName).Append('.').Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).AppendLine("\" --% -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")").
Append("// dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~_Tests.").Append(loopName).Append('.').Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append(" & ClassName~").Append(cellInstanceNameWithoutHyphen).AppendLine("\" --% -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")").
Append("// dotnet test --runtime win-x64 --no-build --filter \"FullyQualifiedName~_Tests.").Append(loopName).Append('.').Append(_Environment).Append('.').Append(cellInstanceVersionNameAsCode).Append(" & ClassName~").Append(cellInstanceNameWithoutHyphen).Append(" & ").Append(methodName).AppendLine("\" --% -- TestRunParameters.Parameter(name=\\\"Debug\\\", value=\\\"Debugger.IsAttached\\\")");
AppendLine();
if (i == 2)
extractText = stringBuilder.ToString().Trim();
else if (i == 1)