Ready to test

This commit is contained in:
2022-02-18 16:42:50 -07:00
parent 6259bd1996
commit ce231b256a
149 changed files with 16269 additions and 10552 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Shared;
public class EAFLoggingUnitTesting : LoggingUnitTesting, IDisposable
{
protected readonly AdaptationTesting _AdaptationTesting;
public AdaptationTesting AdaptationTesting => _AdaptationTesting;
public EAFLoggingUnitTesting(TestContext testContext, Type declaringType, bool skipEquipmentDictionary) :
base(testContext, declaringType)
{
if (testContext is null || declaringType is null)
_AdaptationTesting = null;
else
_AdaptationTesting = new AdaptationTesting(testContext, skipEquipmentDictionary);
}
public new void Dispose()
{
base.Dispose();
GC.SuppressFinalize(this);
}
}

View File

@ -0,0 +1,168 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Shared;
public class IsEnvironment
{
public enum Name
{
LinuxDevelopment,
LinuxProduction,
LinuxStaging,
OSXDevelopment,
OSXProduction,
OSXStaging,
WindowsDevelopment,
WindowsProduction,
WindowsStaging
}
public bool DebuggerWasAttachedDuringConstructor { get; private set; }
public bool Development { get; private set; }
public bool Linux { get; private set; }
public bool OSX { get; private set; }
public bool Production { get; private set; }
public bool Staging { get; private set; }
public bool Windows { get; private set; }
public string Profile { get; private set; }
public string AppSettingsFileName { get; private set; }
public string ASPNetCoreEnvironment { get; private set; }
public IsEnvironment(string testCategory)
{
if (testCategory.EndsWith(".json"))
{
Production = testCategory == "appsettings.json";
Staging = testCategory.EndsWith(nameof(Staging));
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Development = testCategory.EndsWith(nameof(Development));
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
}
else
{
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
OSX = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(OSX));
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Linux = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Linux));
Staging = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Staging));
Windows = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Windows));
Production = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Production));
Development = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Development));
}
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
}
public IsEnvironment(bool isDevelopment, bool isStaging, bool isProduction)
{
Staging = isStaging;
Production = isProduction;
Development = isDevelopment;
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
}
public IsEnvironment(int? processesCount, bool nullASPNetCoreEnvironmentIsDevelopment, bool nullASPNetCoreEnvironmentIsProduction)
{
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (nullASPNetCoreEnvironmentIsDevelopment && nullASPNetCoreEnvironmentIsProduction)
throw new Exception();
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsProduction)
Production = true;
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsDevelopment)
Development = true;
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && !nullASPNetCoreEnvironmentIsDevelopment && !nullASPNetCoreEnvironmentIsProduction)
throw new Exception();
else
{
Staging = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Staging));
Production = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Production));
Development = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Development));
}
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount);
}
private string GetProfile()
{
string result;
if (Windows && Production)
result = nameof(Production);
else if (Windows && Staging)
result = nameof(Staging);
else if (Windows && Development)
result = nameof(Development);
else if (Linux && Production)
result = nameof(Name.LinuxProduction);
else if (Linux && Staging)
result = nameof(Name.LinuxStaging);
else if (Linux && Development)
result = nameof(Name.LinuxDevelopment);
else if (OSX && Production)
result = nameof(Name.OSXProduction);
else if (OSX && Staging)
result = nameof(Name.OSXStaging);
else if (OSX && Development)
result = nameof(Name.OSXDevelopment);
else
throw new Exception();
return result;
}
private string GetAppSettingsFileName(int? processesCount)
{
string result;
if (Production)
{
if (processesCount is null)
result = "appsettings.json";
else
result = $"appsettings.{processesCount}.json";
}
else
{
string environment;
if (Staging)
environment = nameof(Staging);
else if (Development)
environment = nameof(Development);
else
throw new Exception();
if (processesCount is null)
result = $"appsettings.{environment}.json";
else
result = $"appsettings.{environment}.{processesCount}.json";
}
return result;
}
public static string GetEnvironmentName(IsEnvironment isEnvironment)
{
string result;
if (isEnvironment.Windows)
result = nameof(IsEnvironment.Windows);
else if (isEnvironment.Linux)
result = nameof(IsEnvironment.Linux);
else if (isEnvironment.OSX)
result = nameof(IsEnvironment.OSX);
else
throw new Exception();
return result;
}
}

View File

@ -0,0 +1,111 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
namespace Shared;
public class LoggingUnitTesting : UnitTesting, IDisposable
{
protected ILogger<object> _Logger;
protected ILoggerFactory _LoggerFactory;
protected readonly LogLevel? _DefaultLogLevel;
protected readonly LogLevel? _Log4netProviderLogLevel;
protected readonly IConfigurationRoot _ConfigurationRoot;
public ILogger<object> Logger => _Logger;
public LogLevel? DefaultLogLevel => _DefaultLogLevel;
public ILoggerFactory LoggerFactory => _LoggerFactory;
public IConfigurationRoot ConfigurationRoot => _ConfigurationRoot;
public LogLevel? Log4netProviderLogLevel => _Log4netProviderLogLevel;
public LoggingUnitTesting(TestContext testContext, Type declaringType) :
base(testContext, declaringType)
{
_LoggerFactory = new LoggerFactory();
if (testContext is null || declaringType is null)
{
_ConfigurationRoot = null;
_DefaultLogLevel = null;
_Log4netProviderLogLevel = null;
}
else
{
LogLevel logLevel;
IConfigurationSection configurationSection;
List<LogLevel> logLevels = new();
string defaultLogLevelSection = "Logging:LogLevel:Default";
string log4netProviderLogLevelSection = "Logging:LogLevel:Log4netProvider";
string[] sections = new string[] { defaultLogLevelSection, log4netProviderLogLevelSection };
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile(_IsEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
_ConfigurationRoot = configurationBuilder.Build();
foreach (string section in sections)
{
configurationSection = _ConfigurationRoot.GetSection(section);
if (configurationSection is null)
logLevel = LogLevel.Debug;
else if (!Enum.TryParse<LogLevel>(configurationSection.Value, out logLevel))
logLevel = LogLevel.Debug;
logLevels.Add(logLevel);
}
_DefaultLogLevel = logLevels[0];
_Log4netProviderLogLevel = logLevels[1];
}
if (DefaultLogLevel.HasValue)
_LoggerFactory.AddProvider(new DebugProvider(DefaultLogLevel.Value));
if (DefaultLogLevel.HasValue)
_LoggerFactory.AddProvider(new ConsoleProvider(DefaultLogLevel.Value));
_Logger = _LoggerFactory.CreateLogger<object>();
}
public static string GetEnvironmentSpecialDirectory()
{
string result = string.Empty;
string traceFile;
List<string> directories = new();
Environment.SpecialFolder[] specialFolders = new Environment.SpecialFolder[]
{
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolder.ApplicationData,
Environment.SpecialFolder.History,
Environment.SpecialFolder.CommonApplicationData,
Environment.SpecialFolder.InternetCache
};
foreach (Environment.SpecialFolder specialFolder in specialFolders)
directories.Add(Environment.GetFolderPath(specialFolder));
foreach (string directory in directories)
{
for (int i = 1; i < 3; i++)
{
if (i == 1)
result = directory;
else
result = string.Concat("D", directory.Substring(1));
try
{
if (!Directory.Exists(result))
_ = Directory.CreateDirectory(result);
traceFile = string.Concat(result, @"\", DateTime.Now.Ticks, ".txt");
File.WriteAllText(traceFile, traceFile);
File.Delete(traceFile);
break;
}
catch (Exception) { result = string.Empty; }
}
if (!string.IsNullOrEmpty(result))
break;
}
return result;
}
public void Dispose()
{
_LoggerFactory.Dispose();
GC.SuppressFinalize(this);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
using System.Xml.Serialization;
namespace Shared.PasteSpecialXml.EAF.XML.API.ConfigurationData;
[XmlRoot(ElementName = "ChildBackboneMembers", Namespace = "http://schemas.datacontract.org/2004/07/EafManagement.Configuration.Services")]
public class ChildBackboneMembers
{
[XmlAttribute(AttributeName = "nil", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
public string Nil { get; set; }
}
[XmlRoot(ElementName = "ConfigurationData", Namespace = "http://schemas.datacontract.org/2004/07/EafManagement.Configuration.Services")]
public class ConfigurationData
{
[XmlElement(ElementName = "ChildBackboneMembers", Namespace = "http://schemas.datacontract.org/2004/07/EafManagement.Configuration.Services")]
public ChildBackboneMembers ChildBackboneMembers { get; set; }
[XmlElement(ElementName = "Data", Namespace = "http://schemas.datacontract.org/2004/07/EafManagement.Configuration.Services")]
public string Data { get; set; }
[XmlAttribute(AttributeName = "xmlns")]
public string Xmlns { get; set; }
[XmlAttribute(AttributeName = "i", Namespace = "http://www.w3.org/2000/xmlns/")]
public string I { get; set; }
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,962 @@
namespace Shared.PasteSpecialXml.EAF.XML.API.EquipmentType;
// NOTE: Generated code may require at least .NET Framework 4.5 or .NET Core/Standard 2.0.
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.FactoryEntities")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.FactoryEntities", IsNullable = false)]
public partial class EquipmentTypeVersion
{
#pragma warning disable IDE1006 // Naming Styles
private string createdByField;
private System.DateTime creationDateField;
private object descriptionField;
private ExtensionsVersionExtension[] extensionsField;
private System.DateTime freezeDateField;
private string frozenByField;
private byte idField;
private bool isFrozenField;
private bool isRetiredField;
private System.DateTime retireDateField;
private object retiredByField;
private SelectedDeploymentPackage[] deploymentPackagesField;
private EquipmentTypeVersionDictionaries dictionariesField;
private string nameField;
private EquipmentTypeVersionParentType parentTypeField;
private ParameterizedModelObjectDefinition[] equipmentComponentsField;
private EventActionSequenceDefinition[] eventActionSequencesField;
private object fileCommunicatorObjectTypesField;
private FileConfiguration fileConfigurationField;
private FileHandlerObjectTypes fileHandlerObjectTypesField;
private ParameterizedModelObjectDefinition[] transientEquipmentObjectTypesField;
private string id1Field;
private string i___typeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public string CreatedBy
{
get => this.createdByField;
set => this.createdByField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public System.DateTime CreationDate
{
get => this.creationDateField;
set => this.creationDateField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities", IsNullable = true)]
public object Description
{
get => this.descriptionField;
set => this.descriptionField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
[System.Xml.Serialization.XmlArrayItemAttribute("VersionExtension", IsNullable = false)]
public ExtensionsVersionExtension[] Extensions
{
get => this.extensionsField;
set => this.extensionsField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public System.DateTime FreezeDate
{
get => this.freezeDateField;
set => this.freezeDateField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public string FrozenBy
{
get => this.frozenByField;
set => this.frozenByField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public bool IsFrozen
{
get => this.isFrozenField;
set => this.isFrozenField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public bool IsRetired
{
get => this.isRetiredField;
set => this.isRetiredField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public System.DateTime RetireDate
{
get => this.retireDateField;
set => this.retireDateField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities", IsNullable = true)]
public object RetiredBy
{
get => this.retiredByField;
set => this.retiredByField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("SelectedDeploymentPackage", Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.Deployme" +
"nt", IsNullable = false)]
public SelectedDeploymentPackage[] DeploymentPackages
{
get => this.deploymentPackagesField;
set => this.deploymentPackagesField = value;
}
/// <remarks/>
public EquipmentTypeVersionDictionaries Dictionaries
{
get => this.dictionariesField;
set => this.dictionariesField = value;
}
/// <remarks/>
public string Name
{
get => this.nameField;
set => this.nameField = value;
}
/// <remarks/>
public EquipmentTypeVersionParentType ParentType
{
get => this.parentTypeField;
set => this.parentTypeField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlArrayItemAttribute("ParameterizedModelObjectDefinition", Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation", IsNullable = false)]
public ParameterizedModelObjectDefinition[] EquipmentComponents
{
get => this.equipmentComponentsField;
set => this.equipmentComponentsField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlArrayItemAttribute("EventActionSequenceDefinition", Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation", IsNullable = false)]
public EventActionSequenceDefinition[] EventActionSequences
{
get => this.eventActionSequencesField;
set => this.eventActionSequencesField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
public object FileCommunicatorObjectTypes
{
get => this.fileCommunicatorObjectTypesField;
set => this.fileCommunicatorObjectTypesField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
public FileConfiguration FileConfiguration
{
get => this.fileConfigurationField;
set => this.fileConfigurationField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
public FileHandlerObjectTypes FileHandlerObjectTypes
{
get => this.fileHandlerObjectTypesField;
set => this.fileHandlerObjectTypesField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlArrayItemAttribute("ParameterizedModelObjectDefinition", Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation", IsNullable = false)]
public ParameterizedModelObjectDefinition[] TransientEquipmentObjectTypes
{
get => this.transientEquipmentObjectTypesField;
set => this.transientEquipmentObjectTypesField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string i___type
{
get => this.i___typeField;
set => this.i___typeField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.Deployme" +
"nt")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.Deployme" +
"nt", IsNullable = false)]
public partial class SelectedDeploymentPackage
{
private byte idField;
private string packageNameField;
private string packageVersionField;
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
public string PackageName
{
get => this.packageNameField;
set => this.packageNameField = value;
}
/// <remarks/>
public string PackageVersion
{
get => this.packageVersionField;
set => this.packageVersionField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
public partial class ExtensionsVersionExtension
{
private byte idField;
private string classNameField;
private object configurationField;
private string nameField;
private string id1Field;
private string i___typeField;
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.Backbone" +
"s")]
public string ClassName
{
get => this.classNameField;
set => this.classNameField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.Backbone" +
"s", IsNullable = true)]
public object Configuration
{
get => this.configurationField;
set => this.configurationField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.Backbone" +
"s")]
public string Name
{
get => this.nameField;
set => this.nameField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string i___type
{
get => this.i___typeField;
set => this.i___typeField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.FactoryEntities")]
public partial class EquipmentTypeVersionDictionaries
{
private EquipmentTypeVersionDictionariesEquipmentTypeDictionaryReference equipmentTypeDictionaryReferenceField;
/// <remarks/>
public EquipmentTypeVersionDictionariesEquipmentTypeDictionaryReference EquipmentTypeDictionaryReference
{
get => this.equipmentTypeDictionaryReferenceField;
set => this.equipmentTypeDictionaryReferenceField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.FactoryEntities")]
public partial class EquipmentTypeVersionDictionariesEquipmentTypeDictionaryReference
{
private string dictionaryNameField;
private string dictionaryVersionField;
private byte idField;
private string id1Field;
/// <remarks/>
public string DictionaryName
{
get => this.dictionaryNameField;
set => this.dictionaryNameField = value;
}
/// <remarks/>
public string DictionaryVersion
{
get => this.dictionaryVersionField;
set => this.dictionaryVersionField = value;
}
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.FactoryEntities")]
public partial class EquipmentTypeVersionParentType
{
private byte idField;
private string nameField;
private string id1Field;
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
public string Name
{
get => this.nameField;
set => this.nameField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation", IsNullable = false)]
public partial class ParameterizedModelObjectDefinition
{
private byte idField;
private string nameField;
private ParameterizedModelObjectDefinitionModelObjectParameterDefinition[] parametersField;
private string typeField;
private string id1Field;
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
public string Name
{
get => this.nameField;
set => this.nameField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("ModelObjectParameterDefinition", IsNullable = false)]
public ParameterizedModelObjectDefinitionModelObjectParameterDefinition[] Parameters
{
get => this.parametersField;
set => this.parametersField = value;
}
/// <remarks/>
public string Type
{
get => this.typeField;
set => this.typeField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
public partial class ParameterizedModelObjectDefinitionModelObjectParameterDefinition
{
private string enumTypeField;
private byte idField;
private string nameField;
private string valueField;
private string valueTypeField;
private string id1Field;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public string EnumType
{
get => this.enumTypeField;
set => this.enumTypeField = value;
}
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
public string Name
{
get => this.nameField;
set => this.nameField = value;
}
/// <remarks/>
public string Value
{
get => this.valueField;
set => this.valueField = value;
}
/// <remarks/>
public string ValueType
{
get => this.valueTypeField;
set => this.valueTypeField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation", IsNullable = false)]
public partial class EventActionSequenceDefinition
{
private EventActionSequenceDefinitionEventActionParameterDefinition[] actionsField;
private string eventTypeField;
private string handledEventField;
private byte idField;
private string id1Field;
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("EventActionParameterDefinition", IsNullable = false)]
public EventActionSequenceDefinitionEventActionParameterDefinition[] Actions
{
get => this.actionsField;
set => this.actionsField = value;
}
/// <remarks/>
public string EventType
{
get => this.eventTypeField;
set => this.eventTypeField = value;
}
/// <remarks/>
public string HandledEvent
{
get => this.handledEventField;
set => this.handledEventField = value;
}
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes", IsNullable = false)]
public class FileConfiguration
{
private string idField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id
{
get => this.idField;
set => this.idField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes", IsNullable = false)]
public class FileHandlerObjectTypes
{
private ParameterizedModelObjectDefinition parameterizedModelObjectDefinitionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
public ParameterizedModelObjectDefinition ParameterizedModelObjectDefinition
{
get => this.parameterizedModelObjectDefinitionField;
set => this.parameterizedModelObjectDefinitionField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.FactoryE" +
"ntities", IsNullable = false)]
public partial class Extensions
{
private ExtensionsVersionExtension[] versionExtensionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("VersionExtension")]
public ExtensionsVersionExtension[] VersionExtension
{
get => this.versionExtensionField;
set => this.versionExtensionField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes", IsNullable = false)]
public partial class EquipmentComponents
{
private ParameterizedModelObjectDefinition[] parameterizedModelObjectDefinitionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("ParameterizedModelObjectDefinition", Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
public ParameterizedModelObjectDefinition[] ParameterizedModelObjectDefinition
{
get => this.parameterizedModelObjectDefinitionField;
set => this.parameterizedModelObjectDefinitionField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes", IsNullable = false)]
public partial class EventActionSequences
{
private EventActionSequenceDefinition[] eventActionSequenceDefinitionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("EventActionSequenceDefinition", Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
public EventActionSequenceDefinition[] EventActionSequenceDefinition
{
get => this.eventActionSequenceDefinitionField;
set => this.eventActionSequenceDefinitionField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.datacontract.org/2004/07/EafRuntimeIfx.ManagementInterfaceIfx.File" +
"Connector.EquipmentTypes", IsNullable = false)]
public partial class TransientEquipmentObjectTypes
{
private ParameterizedModelObjectDefinition[] parameterizedModelObjectDefinitionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("ParameterizedModelObjectDefinition", Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
public ParameterizedModelObjectDefinition[] ParameterizedModelObjectDefinition
{
get => this.parameterizedModelObjectDefinitionField;
set => this.parameterizedModelObjectDefinitionField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
public partial class EventActionSequenceDefinitionEventActionParameterDefinition
{
private byte idField;
private object nameField;
private EventActionSequenceDefinitionEventActionParameterDefinitionModelObjectParameterDefinition[] parametersField;
private string typeField;
private byte positionField;
private string id1Field;
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public object Name
{
get => this.nameField;
set => this.nameField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("ModelObjectParameterDefinition", IsNullable = false)]
public EventActionSequenceDefinitionEventActionParameterDefinitionModelObjectParameterDefinition[] Parameters
{
get => this.parametersField;
set => this.parametersField = value;
}
/// <remarks/>
public string Type
{
get => this.typeField;
set => this.typeField = value;
}
/// <remarks/>
public byte Position
{
get => this.positionField;
set => this.positionField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.datacontract.org/2004/07/Eaf.Management.ConfigurationData.CellAuto" +
"mation")]
public partial class EventActionSequenceDefinitionEventActionParameterDefinitionModelObjectParameterDefinition
{
private object categoryField;
private object descriptionField;
private object displayNameField;
private object enumTypeField;
private byte idField;
private bool isMandatoryField;
private string nameField;
private byte orderField;
private string valueField;
private string valueTypeField;
private string id1Field;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public object Category
{
get => this.categoryField;
set => this.categoryField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public object Description
{
get => this.descriptionField;
set => this.descriptionField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public object DisplayName
{
get => this.displayNameField;
set => this.displayNameField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
public object EnumType
{
get => this.enumTypeField;
set => this.enumTypeField = value;
}
/// <remarks/>
public byte Id
{
get => this.idField;
set => this.idField = value;
}
/// <remarks/>
public bool IsMandatory
{
get => this.isMandatoryField;
set => this.isMandatoryField = value;
}
/// <remarks/>
public string Name
{
get => this.nameField;
set => this.nameField = value;
}
/// <remarks/>
public byte Order
{
get => this.orderField;
set => this.orderField = value;
}
/// <remarks/>
public string Value
{
get => this.valueField;
set => this.valueField = value;
}
/// <remarks/>
public string ValueType
{
get => this.valueTypeField;
set => this.valueTypeField = value;
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute("Id", Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2003/10/Serialization/")]
public string Id1
{
get => this.id1Field;
set => this.id1Field = value;
}
}

View File

@ -0,0 +1,90 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading;
namespace Shared;
public class UnitTesting
{
protected readonly IsEnvironment _IsEnvironment;
public IsEnvironment IsEnvironment => _IsEnvironment;
public UnitTesting(TestContext testContext, Type declaringType)
{
if (testContext is null || declaringType is null)
_IsEnvironment = null;
else
{
string projectDirectory = GetProjectDirectory(testContext);
string json = JsonSerializer.Serialize(testContext.Properties);
string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode");
if (!Directory.Exists(vsCodeDirectory))
_ = Directory.CreateDirectory(vsCodeDirectory);
string launchText = GetLaunchText();
File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText);
for (int i = 0; i < int.MaxValue; i++)
{
if (!json.Contains("Debugger.IsAttached") || Debugger.IsAttached)
break;
Thread.Sleep(500);
}
MethodBase methodBase = declaringType.GetMethod(testContext.TestName);
if (methodBase is not null)
{
TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute<TestCategoryAttribute>();
if (testCategoryAttribute is not null)
{
foreach (string testCategory in testCategoryAttribute.TestCategories)
_IsEnvironment = new IsEnvironment(testCategory);
}
}
if (_IsEnvironment is null)
_IsEnvironment = new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached);
}
}
internal static string GetProjectDirectory(TestContext testContext)
{
string result;
string[] checkFiles = null;
result = Path.GetDirectoryName(testContext.DeploymentDirectory);
for (int i = 0; i < int.MaxValue; i++)
{
if (string.IsNullOrEmpty(result))
break;
checkFiles = Directory.GetFiles(result, "*.Tests.*proj", SearchOption.TopDirectoryOnly);
if (checkFiles.Any())
break;
result = Path.GetDirectoryName(result);
}
if (string.IsNullOrEmpty(result) || checkFiles is null || !checkFiles.Any())
throw new Exception(result);
return result;
}
internal static string GetLaunchText()
{
StringBuilder result = new();
_ = result.
AppendLine("{").
AppendLine(" \"configurations\": [").
AppendLine(" {").
AppendLine(" \"name\": \".NET Core Attach\",").
AppendLine(" \"type\": \"coreclr\",").
AppendLine(" \"request\": \"attach\",").
AppendLine($" \"processId\": {Environment.ProcessId}").
AppendLine(" }").
AppendLine(" ]").
AppendLine("}");
return result.ToString();
}
}