json body Path.GetDirectoryName(_FileConnectorConfiguration.AlternateTargetFolder) PostOpenInsightMetrologyViewerAttachments Ready to test InterceptIQS Version Error Message Using pattern ... Tests Passed CA1862 and GetWeekOfYear for WritePDSF Commit a0c1c665: Save Copy - sql or json gitignore cellInstanceVersion.EdaConnection.PortNumber cellInstanceVersion.EdaConnection.PortNumber Added Climatec to Test.cs GetJobIdDirectory Remove and NETFRAMEWORK 5-Other-Small
128 lines
4.6 KiB
C#
128 lines
4.6 KiB
C#
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 MET08RESIHGCV : LoggingUnitTesting, IDisposable
|
||
{
|
||
|
||
#pragma warning disable CA2254
|
||
#pragma warning disable IDE0060
|
||
|
||
internal static MET08RESIHGCV LoggingUnitTesting { get; private set; }
|
||
|
||
public MET08RESIHGCV() : base(testContext: null, declaringType: null)
|
||
{
|
||
if (LoggingUnitTesting is null)
|
||
throw new Exception();
|
||
}
|
||
|
||
public MET08RESIHGCV(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType)
|
||
{
|
||
}
|
||
|
||
[ClassInitialize]
|
||
public static void ClassInitialize(TestContext testContext) => LoggingUnitTesting ??= new MET08RESIHGCV(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 Staging()
|
||
{
|
||
MethodBase methodBase = new StackFrame().GetMethod();
|
||
StringBuilder results = new();
|
||
(string cellInstanceName, string cellInstanceVersionName)[] collection = new (string, string)[]
|
||
{
|
||
new("MET08RESIHGCV", "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"));
|
||
}
|
||
|
||
[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<string> 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();
|
||
}
|
||
|
||
[TestMethod]
|
||
public void TestDeltaMean()
|
||
{
|
||
// (0.3864 – 0.4286) / 0.4286 * 100 = -9.846 %
|
||
float a = 0.4286f;
|
||
float b = 0.3864f;
|
||
float c = 100;
|
||
float d = -9.84601f;
|
||
Assert.IsTrue((b - a) / a * c == d);
|
||
NonThrowTryCatch();
|
||
}
|
||
|
||
[TestMethod]
|
||
public void TestSubgroupId()
|
||
{
|
||
int subgroupId = 1715715363;
|
||
DateTime ticksDateTime = new(638512869386943434);
|
||
DateTime epicDateTime = new(1970, 01, 01, 0, 0, 0, DateTimeKind.Utc);
|
||
DateTime subgroupIdDateTime = epicDateTime.AddSeconds(subgroupId).ToLocalTime();
|
||
TimeSpan timeSpan = new(ticksDateTime.Ticks - subgroupIdDateTime.Ticks);
|
||
Assert.IsTrue(timeSpan.TotalHours is < 1 and > (-1));
|
||
NonThrowTryCatch();
|
||
}
|
||
|
||
} |