- Include root in valid directories

- AppSetting bug fix

- Updated testes with base test class and editor configuration changes

- Created new server and wafer counter tasks json files and pipelines to match
This commit is contained in:
2025-07-29 16:56:09 -07:00
parent 6f52566fc2
commit a427c5648a
49 changed files with 1680 additions and 822 deletions

6
Tests/.vscode/mklink.md vendored Normal file
View File

@ -0,0 +1,6 @@
# mklink
```bash Thu Aug 29 2024 09:47:22 GMT-0700 (Mountain Standard Time)
mklink /J "L:\DevOps\OpenInsight-Metrology-Viewer\OI-Metrology\Tests\.vscode\.UserSecrets-Server" "C:\Users\phares\AppData\Roaming\Microsoft\UserSecrets\b0a3891c-b775-422c-80ee-63a2f385045d"
mklink /J "L:\DevOps\OpenInsight-Metrology-Viewer\OI-Metrology\Tests\.vscode\.UserSecrets-Wafer-Counter" "C:\Users\phares\AppData\Roaming\Microsoft\UserSecrets\2a0acd34-8f61-47a3-8818-73fa8fe04902"
```

View File

@ -1,6 +1,24 @@
{
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/**",
"cSpell.words": [
"datebegin"
"appsettings",
"BIORAD",
"datebegin",
"dateend",
"Dispo",
"headerid",
"headertitles",
"infineon",
"markasawaiting",
"markasreviewed",
"mesfs",
"messa",
"Newtonsoft",
"pdsf",
"RESIMAPCDE",
"ROTR",
"SGRP",
"Tencor",
"TSNO"
]
}

View File

@ -2,43 +2,57 @@
"version": "2.0.0",
"tasks": [
{
"label": "build",
"label": "Build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/OI.Metrology.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
"build"
],
"problemMatcher": "$msCompile"
},
{
"label": "testDebug",
"label": "Test Debug",
"command": "dotnet",
"type": "process",
"args": [
"test",
"${workspaceFolder}/OI.Metrology.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
"--settings:test.runsettings"
],
"problemMatcher": "$msCompile"
},
{
"label": "testRelease",
"label": "Test Debug with Settings",
"command": "dotnet",
"type": "process",
"args": [
"test",
"--settings:Settings.xml"
],
"problemMatcher": "$msCompile"
},
{
"label": "Test Release",
"command": "dotnet",
"type": "process",
"args": [
"test",
"${workspaceFolder}/OI.Metrology.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"-c",
"Release"
],
"problemMatcher": "$msCompile"
},
{
"label": "Test Release with Settings",
"command": "dotnet",
"type": "process",
"args": [
"test",
"-c",
"Release",
"--settings:Settings.xml"
],
"problemMatcher": "$msCompile"
},
{
"label": "Format",
"command": "dotnet",
@ -55,7 +69,7 @@
"problemMatcher": "$msCompile"
},
{
"label": "Format-Whitespace",
"label": "Format Whitespace",
"command": "dotnet",
"type": "process",
"args": [
@ -65,14 +79,11 @@
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"label": "Publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/../Server/OI.Metrology.Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"--configuration",
"Release",
"--runtime",

View File

@ -15,3 +15,6 @@ Accept: application/json
###
GET {{host}}/111/header
Accept: application/json
###
GET https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV3/CDE4_250520183333000/header

21
Tests/BaseTestClass.cs Normal file
View File

@ -0,0 +1,21 @@
using System.Diagnostics;
namespace OI.Metrology.Tests;
public class BaseTestClass
{
private static int _FailedTests;
private readonly int _Threshold = 5;
protected void IncrementFailedTests()
{
if (++_FailedTests >= _Threshold)
{
for (int i = 0; i < 10; i++)
Thread.Sleep(500);
Process.GetCurrentProcess().Kill();
}
}
}

9
Tests/Settings.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<MSTest>
<Parallelize>
<Workers>0</Workers>
<Scope>MethodLevel</Scope>
</Parallelize>
</MSTest>
</RunSettings>

View File

@ -8,14 +8,14 @@ using System.Net.Http.Json;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitAwaitingDispoController
public class UnitAwaitingDispoController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -23,19 +23,32 @@ public class UnitAwaitingDispoController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.AwaitingDispoController)[..^10];
}
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IAwaitingDispoController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -46,8 +59,8 @@ public class UnitAwaitingDispoController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IEnumerable<AwaitingDisposition>? awaitingDispositions = metrologyRepository?.GetAwaitingDisposition();
Assert.IsTrue(awaitingDispositions is not null);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(awaitingDispositions);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -56,10 +69,10 @@ public class UnitAwaitingDispoController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(IMetrologyRepository.GetAwaitingDisposition)}Api.json"), json);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -70,7 +83,7 @@ public class UnitAwaitingDispoController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
_ = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: false);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -79,9 +92,9 @@ public class UnitAwaitingDispoController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/markasreviewed");
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -93,7 +106,7 @@ public class UnitAwaitingDispoController
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
int? dateCleared = metrologyRepository?.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: true);
Assert.IsTrue(dateCleared <= 1);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -102,9 +115,9 @@ public class UnitAwaitingDispoController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
_ = await httpClient.PostAsync($"api/{_ControllerName}/markasawaiting", null);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -115,7 +128,7 @@ public class UnitAwaitingDispoController
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
Guid? guid = metrologyRepository?.GetHeaderAttachmentID(toolTypeId: 1, headerId: 1);
Assert.IsNotNull(guid);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -123,10 +136,10 @@ public class UnitAwaitingDispoController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/1/header-attachment-id?headerid=1");
Assert.IsNotNull(httpResponseMessage.Content);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(httpResponseMessage.Content.ToString());
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
}

View File

@ -8,14 +8,14 @@ using System.Text;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitInboundController
public class UnitInboundController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -23,7 +23,6 @@ public class UnitInboundController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -37,12 +36,19 @@ public class UnitInboundController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInboundController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -58,9 +64,9 @@ public class UnitInboundController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
_ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad", GetStringContent());
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -70,9 +76,9 @@ public class UnitInboundController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
_ = await httpClient.PostAsync($"api/{_ControllerName}/BioRad/attachment", GetStringContent());
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -8,14 +8,14 @@ using System.Net;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestAppSettingsController
public class UnitTestAppSettingsController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -23,7 +23,6 @@ public class UnitTestAppSettingsController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -37,23 +36,31 @@ public class UnitTestAppSettingsController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IAppSettingsController<object>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
[TestMethod]
public void TestConnectionString()
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
appSettingsRepository?.VerifyConnectionStrings();
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
IAppSettingsRepository<AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<AppSettings>>();
_ = Assert.ThrowsException<NotSupportedException>(() => appSettingsRepository?.VerifyConnectionStrings());
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -64,7 +71,7 @@ public class UnitTestAppSettingsController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
AppSettings? appSettings = serviceProvider?.GetRequiredService<AppSettings>();
Assert.IsNotNull(appSettings);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -73,10 +80,10 @@ public class UnitTestAppSettingsController
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
Server.Models.Binder.AppSettings? appSettings = appSettingsRepository?.GetAppSettings();
Assert.IsTrue(appSettings is not null);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
IAppSettingsRepository<AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<AppSettings>>();
AppSettings? appSettings = appSettingsRepository?.GetAppSettings();
Assert.IsNotNull(appSettings);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -85,16 +92,17 @@ public class UnitTestAppSettingsController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string actionName = nameof(IAppSettingsController<object>.Action.App);
HttpResponseMessage? httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string json = await httpResponseMessage.Content.ReadAsStringAsync();
Assert.IsNotNull(httpResponseMessage.Content.Headers.ContentType);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType.ToString());
string? json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAppSettings)}.json"), json);
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreNotEqual("[]", json);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -103,10 +111,10 @@ public class UnitTestAppSettingsController
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
IAppSettingsRepository<AppSettings>? appSettingsRepository = serviceProvider?.GetRequiredService<IAppSettingsRepository<AppSettings>>();
string? result = appSettingsRepository?.GetBuildNumberAndGitCommitSeven();
Assert.IsTrue(result is not null);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -115,15 +123,16 @@ public class UnitTestAppSettingsController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string actionName = nameof(IAppSettingsController<object>.Action.DevOps);
HttpResponseMessage? httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string json = await httpResponseMessage.Content.ReadAsStringAsync();
Assert.IsNotNull(httpResponseMessage.Content.Headers.ContentType);
Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType.ToString());
string? json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetBuildNumberAndGitCommitSeven)}.json"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -7,14 +7,14 @@ using System.Net;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestClientSettingsController
public class UnitTestClientSettingsController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -22,21 +22,37 @@ public class UnitTestClientSettingsController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ClientSettingsController)[..^10];
}
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IClientSettingsController<object>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
#if DEBUG
[Ignore]
#endif
[TestMethod]
public void GetClientSettings()
{
@ -45,31 +61,33 @@ public class UnitTestClientSettingsController
IClientSettingsRepository? clientSettingsRepository = serviceProvider?.GetRequiredService<IClientSettingsRepository>();
#if DEBUG
List<string>? clientSettings = clientSettingsRepository?.GetClientSettings(null);
Assert.IsTrue(clientSettings is not null);
Assert.IsNotNull(clientSettings);
#endif
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
#pragma warning disable CS1998
#if DEBUG
[Ignore]
#endif
[TestMethod]
public async Task GetClientSettingsApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
#if DEBUG
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string actionName = nameof(IClientSettingsController<object>.Action.Client);
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string json = await httpResponseMessage.Content.ReadAsStringAsync();
Assert.IsNotNull(httpResponseMessage.Content.Headers.ContentType);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType.ToString());
string? json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetClientSettings)}.json"), json);
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
Assert.AreNotEqual("[]", json);
#endif
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
#pragma warning restore CS1998
[TestMethod]
public void GetIpAddress()
@ -78,8 +96,8 @@ public class UnitTestClientSettingsController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IClientSettingsRepository? clientSettingsRepository = serviceProvider?.GetRequiredService<IClientSettingsRepository>();
string? ipAddress = clientSettingsRepository?.GetIpAddress(null);
Assert.IsTrue(ipAddress is not null);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(ipAddress);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -87,15 +105,16 @@ public class UnitTestClientSettingsController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string actionName = nameof(IClientSettingsController<object>.Action.IP);
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string json = await httpResponseMessage.Content.ReadAsStringAsync();
Assert.IsNotNull(httpResponseMessage.Content.Headers.ContentType);
Assert.AreEqual("text/plain; charset=utf-8", httpResponseMessage.Content.Headers.ContentType.ToString());
string? json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetIpAddress)}.json"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
}

View File

@ -9,14 +9,14 @@ using System.Text;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestExportController
public class UnitTestExportController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -24,7 +24,6 @@ public class UnitTestExportController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -38,12 +37,19 @@ public class UnitTestExportController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IExportController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -61,7 +67,7 @@ public class UnitTestExportController
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
string? result = exportRepository?.GetExport(GetHeaderCommon());
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -70,11 +76,11 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/export");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -83,10 +89,10 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreEqual(System.Net.HttpStatusCode.OK, httpResponseMessage.StatusCode);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -98,7 +104,7 @@ public class UnitTestExportController
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Result<HeaderCommon[]>? result = exportRepository?.GetHeaders(GetHeaderCommon());
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -107,12 +113,12 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json);
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -121,10 +127,10 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreEqual(System.Net.HttpStatusCode.OK, httpResponseMessage.StatusCode);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -136,7 +142,7 @@ public class UnitTestExportController
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Result<HeaderCommon[]>? result = exportRepository?.GetLogistics(GetHeaderCommon());
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -145,12 +151,12 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/logistics");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLogistics)}.json"), json);
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -159,10 +165,10 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreEqual(System.Net.HttpStatusCode.OK, httpResponseMessage.StatusCode);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -174,7 +180,7 @@ public class UnitTestExportController
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
string? result = exportRepository?.GetProcessDataStandardFormat(GetHeaderCommon());
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -183,11 +189,11 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/processDataStandardFormat");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -196,10 +202,10 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent());
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreEqual(System.Net.HttpStatusCode.OK, httpResponseMessage.StatusCode);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -211,11 +217,11 @@ public class UnitTestExportController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
Result<DataTable>? result = exportRepository?.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -224,15 +230,16 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/export?datebegin=&dateend=");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExportData)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
[TestMethod]
public void GetCSVExport()
{
@ -240,10 +247,10 @@ public class UnitTestExportController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
string? result = exportRepository?.GetCSVExport(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -252,11 +259,11 @@ public class UnitTestExportController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/1/csv?datebegin=&dateend=");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCSVExport)}.csv"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
}

View File

@ -9,14 +9,14 @@ using System.Collections.ObjectModel;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestFileShareController
public class UnitTestFileShareController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Wafer.Counter.Program>? _WebApplicationFactory;
#pragma warning restore
@ -24,7 +24,6 @@ public class UnitTestFileShareController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Wafer.Counter.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Wafer.Counter.Program>>();
@ -39,12 +38,19 @@ public class UnitTestFileShareController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IFileShareController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -54,10 +60,10 @@ public class UnitTestFileShareController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? response = await httpClient.GetStringAsync($"api/v1/file-share/copy-file/?from=\\\\mesfs.infineon.com\\EC_Metrology_Si\\MetrologyAttachments\\CDERunHeader_\\2024\\WW11\\247233\\CDE5_240315162756858.pdsf&to=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\a.pdsf");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -67,25 +73,29 @@ public class UnitTestFileShareController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? response = await httpClient.GetStringAsync($"api/v1/file-share/move-file/?from=\\\\mesfs.infineon.com\\EC_Metrology_Si\\MetrologyAttachments\\CDERunHeader_\\2024\\WW11\\247233\\CDE5_240315162756858.pdsf&to=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\a.pdsf");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public async Task FileWriteApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? response = await httpClient.GetStringAsync($"api/v1/file-share/file-write/?path=\\\\messa01ec.infineon.com\\apps\\Metrology\\MET08RESIMAPCDE\\Test\\b.pdsf&contents=b");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
#if DEBUG
[Ignore]
#endif
[TestMethod]
public void GetArchiveData()
{
@ -94,7 +104,7 @@ public class UnitTestFileShareController
CharacterizationParameters characterizationParameters;
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IFileShareRepository? fileShareRepository = serviceProvider?.GetRequiredService<IFileShareRepository>();
characterizationParameters = new("FQA", "FQA-8INCH", "*.wc", null, null, "8INCH");
characterizationParameters = new("MU", "MU-6INCH", "*.wc", null, null, "6INCH");
result = fileShareRepository?.GetArchiveData(characterizationParameters);
Assert.IsNotNull(result);
characterizationParameters = new(string.Empty, "BIORAD4", "BIO*.json", null, null, "8INCH");
@ -103,22 +113,28 @@ public class UnitTestFileShareController
characterizationParameters = new(string.Empty, "CDE5", "CDE*.json", null, null, "8INCH");
result = fileShareRepository?.GetArchiveData(characterizationParameters);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
#if DEBUG
[Ignore]
#endif
[TestMethod]
public async Task ArchiveDataApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? response = await httpClient.GetStringAsync($"api/v1/file-share/archive-data/?area=FQA&equipment-id=FQA-8INCH&search-pattern=*.wc&wafer-size=8INCH");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
#if DEBUG
[Ignore]
#endif
[TestMethod]
public void EquipmentIds()
{
@ -127,19 +143,22 @@ public class UnitTestFileShareController
IFileShareRepository? fileShareRepository = serviceProvider?.GetRequiredService<IFileShareRepository>();
ReadOnlyCollection<ToolTypeNameId>? result = fileShareRepository?.GetEquipmentIds();
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
#if DEBUG
[Ignore]
#endif
[TestMethod]
public async Task EquipmentIdsApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? response = await httpClient.GetStringAsync($"api/v1/file-share/equipment-ids");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -6,14 +6,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestISpreadingResistanceProfileController
public class UnitTestISpreadingResistanceProfileController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -21,7 +21,6 @@ public class UnitTestISpreadingResistanceProfileController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -35,12 +34,19 @@ public class UnitTestISpreadingResistanceProfileController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(ISpreadingResistanceProfileController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -58,11 +64,11 @@ public class UnitTestISpreadingResistanceProfileController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
ISpreadingResistanceProfileService? spreadingResistanceProfileService = serviceProvider?.GetRequiredService<ISpreadingResistanceProfileService>();
byte[]? bytes = spreadingResistanceProfileService?.GetImageBytes(json);
Assert.IsTrue(bytes is not null);
Assert.IsTrue(bytes.Length != 0);
Assert.IsNotNull(bytes);
Assert.AreNotEqual(0, bytes.Length);
File.WriteAllBytes(Path.Combine(directory, "srp.png"), bytes);
}
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -7,14 +7,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestInfinityQSController
public class UnitTestInfinityQSController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -22,7 +22,6 @@ public class UnitTestInfinityQSController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -36,12 +35,19 @@ public class UnitTestInfinityQSController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInfinityQSController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -56,7 +62,7 @@ public class UnitTestInfinityQSController
IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService<IInfinityQSRepository>();
string? result = infinityQSRepository?.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", "");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -68,11 +74,11 @@ public class UnitTestInfinityQSController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/commandText/?sub_group_id=1677273357&process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -86,14 +92,12 @@ public class UnitTestInfinityQSController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService<IInfinityQSRepository>();
Result<InfinityQSBase[]>? result = infinityQSRepository?.GetData("1677273357");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result?.Results[0].PR_NAME);
Assert.IsNotNull(result?.Results[0].SE_SGTM);
Assert.IsNotNull(result?.Results[0].SE_TSNO);
Assert.IsNotNull(result?.Results[0].TD_NAME);
Assert.IsNotNull(result?.Results[0].TD_TEST);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.IsNotNull(result.Results[0].PR_NAME);
Assert.IsNotNull(result.Results[0].TD_NAME);
Assert.AreNotEqual(0, result.Results.Length);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -105,13 +109,13 @@ public class UnitTestInfinityQSController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357 575908_2023-02-24 14-18-05.txt/data");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json);
Result<InfinityQSBase[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBase[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -125,11 +129,12 @@ public class UnitTestInfinityQSController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService<IInfinityQSRepository>();
Result<InfinityQSDescriptor[]>? result = infinityQSRepository?.GetDescriptors("1677273357");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result?.Results[0].SD_SGRP);
Assert.IsNotNull(result?.Results[0].SD_TSNO);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.IsNotNull(result.Results[0].SD_SGRP);
Assert.IsNotNull(result.Results[0].SD_TSNO);
Assert.AreNotEqual(0, result.Results.Length);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -141,13 +146,13 @@ public class UnitTestInfinityQSController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357 575908_2023-02-24 14-18-05.txt/descriptors");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/descriptors");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json);
Result<InfinityQSDescriptor[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptor[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -162,7 +167,7 @@ public class UnitTestInfinityQSController
IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService<IInfinityQSRepository>();
Result<InfinityQSEvent[]>? result = infinityQSRepository?.GetEvents("1677273357");
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -174,12 +179,12 @@ public class UnitTestInfinityQSController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/events");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEvents)}.json"), json);
Result<InfinityQSEvent[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEvent[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -194,7 +199,7 @@ public class UnitTestInfinityQSController
IInfinityQSRepository? infinityQSRepository = serviceProvider?.GetRequiredService<IInfinityQSRepository>();
Result<InfinityQSBase[]>? result = infinityQSRepository?.GetHeader("1677273357");
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -206,12 +211,12 @@ public class UnitTestInfinityQSController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/header");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json);
Result<InfinityQSBase[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBase[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -7,14 +7,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestInfinityQSV2Controller
public class UnitTestInfinityQSV2Controller : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -22,7 +22,6 @@ public class UnitTestInfinityQSV2Controller
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -36,12 +35,19 @@ public class UnitTestInfinityQSV2Controller
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInfinityQSV2Controller<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -53,7 +59,7 @@ public class UnitTestInfinityQSV2Controller
IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
string? result = infinityQSV2Repository?.GetCommandText("1677273357", "61", "CDE5", "5012", "575908", "");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -65,11 +71,11 @@ public class UnitTestInfinityQSV2Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -83,14 +89,16 @@ public class UnitTestInfinityQSV2Controller
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
Result<InfinityQSBaseV2[]>? result = infinityQSV2Repository?.GetData("1677273357");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.IsNotNull(result.Results[0].Process);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsNotNull(result?.Results[0].Process);
Assert.IsNotNull(result?.Results[0].Variable);
Assert.IsNotNull(result?.Results[0].SiteNumber);
Assert.IsNotNull(result?.Results[0].VariableNumber);
Assert.IsNotNull(result?.Results[0].SubGroupDateTime);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -102,13 +110,13 @@ public class UnitTestInfinityQSV2Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357 575908_2023-02-24 14-18-05.txt/data");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json);
Result<InfinityQSBaseV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBaseV2[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -122,11 +130,12 @@ public class UnitTestInfinityQSV2Controller
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
Result<InfinityQSDescriptorV2[]>? result = infinityQSV2Repository?.GetDescriptors("1677273357");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsNotNull(result?.Results[0].SubGroupId);
Assert.IsNotNull(result?.Results[0].SiteNumber);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -138,13 +147,13 @@ public class UnitTestInfinityQSV2Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357 575908_2023-02-24 14-18-05.txt/descriptors");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/descriptors");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json);
Result<InfinityQSDescriptorV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptorV2[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -159,7 +168,7 @@ public class UnitTestInfinityQSV2Controller
IInfinityQSV2Repository? infinityQSV2Repository = serviceProvider?.GetRequiredService<IInfinityQSV2Repository>();
Result<InfinityQSEventV2[]>? result = infinityQSV2Repository?.GetEvents("1677273357");
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -171,12 +180,12 @@ public class UnitTestInfinityQSV2Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/events");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEvents)}.json"), json);
Result<InfinityQSEventV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSEventV2[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -192,7 +201,7 @@ public class UnitTestInfinityQSV2Controller
Result<InfinityQSBaseV2[]>? result = infinityQSV2Repository?.GetHeader("1677273357");
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -204,13 +213,13 @@ public class UnitTestInfinityQSV2Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1677273357/header");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json);
Result<InfinityQSBaseV2[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSBaseV2[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -7,14 +7,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestInfinityQSV3Controller
public class UnitTestInfinityQSV3Controller : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -22,7 +22,6 @@ public class UnitTestInfinityQSV3Controller
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -36,12 +35,19 @@ public class UnitTestInfinityQSV3Controller
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInfinityQSV3Controller<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -53,7 +59,7 @@ public class UnitTestInfinityQSV3Controller
IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService<IInfinityQSV3Repository>();
string? result = infinityQSV3Repository?.GetCommandText("1698497987", "61", "CDE5", "5012", "575908", "");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -62,11 +68,11 @@ public class UnitTestInfinityQSV3Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -77,14 +83,15 @@ public class UnitTestInfinityQSV3Controller
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService<IInfinityQSV3Repository>();
Result<InfinityQSV3[]>? result = infinityQSV3Repository?.GetData("1698497987");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsNotNull(result?.Results[0].Process);
Assert.IsNotNull(result?.Results[0].Variable);
Assert.IsNotNull(result?.Results[0].SiteNumber);
Assert.IsNotNull(result?.Results[0].VariableNumber);
Assert.IsNotNull(result?.Results[0].SubGroupDateTime);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -93,13 +100,13 @@ public class UnitTestInfinityQSV3Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987 575908_2023-02-24 14-18-05.txt/data");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json);
Result<InfinityQSV3[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSV3[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -110,11 +117,12 @@ public class UnitTestInfinityQSV3Controller
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService<IInfinityQSV3Repository>();
Result<InfinityQSDescriptorV3[]>? result = infinityQSV3Repository?.GetDescriptors("1698497987");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result?.Results[0].SubGroupId);
Assert.IsNotNull(result?.Results[0].SiteNumber);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsNotNull(result.Results[0].SubGroupId);
Assert.IsNotNull(result.Results[0].SiteNumber);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -123,13 +131,13 @@ public class UnitTestInfinityQSV3Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987 575908_2023-02-24 14-18-05.txt/descriptors");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/descriptors");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json);
Result<InfinityQSDescriptorV3[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptorV3[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -142,7 +150,7 @@ public class UnitTestInfinityQSV3Controller
Result<InfinityQSV3[]>? result = infinityQSV3Repository?.GetHeader("1698497987");
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -151,13 +159,13 @@ public class UnitTestInfinityQSV3Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1698497987/header");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json);
Result<InfinityQSV3[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSV3[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -169,7 +177,7 @@ public class UnitTestInfinityQSV3Controller
IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService<IInfinityQSV3Repository>();
string? result = infinityQSV3Repository?.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma("41", "8IN_THIN ROTR");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -178,11 +186,11 @@ public class UnitTestInfinityQSV3Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/41/product-data-average-sum-of-defects-process-mean-process-sigma?recipe=8IN_THIN ROTR");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProductDataAverageSumOfDefectsProcessMeanProcessSigma)}.json"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -195,7 +203,7 @@ public class UnitTestInfinityQSV3Controller
IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService<IInfinityQSV3Repository>();
List<string[]>? results = infinityQSV3Repository?.GetEpiProTempVerificationRows(night);
Assert.IsNotNull(results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -204,11 +212,11 @@ public class UnitTestInfinityQSV3Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/epi-pro-temp-verification-rows/?night=44&night=46&night=52&night=54");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerificationRows)}.json"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -221,7 +229,7 @@ public class UnitTestInfinityQSV3Controller
IInfinityQSV3Repository? infinityQSV3Repository = serviceProvider?.GetRequiredService<IInfinityQSV3Repository>();
string? result = infinityQSV3Repository?.GetEpiProTempVerification(night);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -230,11 +238,11 @@ public class UnitTestInfinityQSV3Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/epi-pro-temp-verification/?night=44&night=46&night=52&night=54");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerification)}.html"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -8,14 +8,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestInfinityQSV4Controller
public class UnitTestInfinityQSV4Controller : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static string _ControllerVersion;
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
@ -24,7 +24,6 @@ public class UnitTestInfinityQSV4Controller
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -39,13 +38,20 @@ public class UnitTestInfinityQSV4Controller
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IInfinityQSV4Controller<string>.GetRouteName(), _ControllerName);
Assert.AreEqual(IInfinityQSV4Controller<string>.GetRouteVersion(), _ControllerVersion);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -57,7 +63,7 @@ public class UnitTestInfinityQSV4Controller
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
string? result = infinityQSV4Repository?.GetCommandText("1718539249", "61", "CDE5", "5012", "575908", "");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -66,11 +72,11 @@ public class UnitTestInfinityQSV4Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/1718539249/commandText/?process=61&job=CDE5&part=5012&lot=575908&date_time=2023-02-24 15:15:00");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCommandText)}.sql"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -81,14 +87,15 @@ public class UnitTestInfinityQSV4Controller
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
Result<InfinityQSV4[]>? result = infinityQSV4Repository?.GetData("1718539249");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsNotNull(result?.Results[0].Process);
Assert.IsNotNull(result?.Results[0].Variable);
Assert.IsNotNull(result?.Results[0].SiteNumber);
Assert.IsNotNull(result?.Results[0].VariableNumber);
Assert.IsNotNull(result?.Results[0].SubGroupDateTime);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -97,13 +104,13 @@ public class UnitTestInfinityQSV4Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/1718539249 575908_2023-02-24 14-18-05.txt/data");
string? json = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/1718539249/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json);
Result<InfinityQSV4[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSV4[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -114,11 +121,12 @@ public class UnitTestInfinityQSV4Controller
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
Result<InfinityQSDescriptorV4[]>? result = infinityQSV4Repository?.GetDescriptors("1718539249");
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsNotNull(result?.Results[0].SubGroupId);
Assert.IsNotNull(result?.Results[0].SiteNumber);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -127,13 +135,13 @@ public class UnitTestInfinityQSV4Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
//string? json = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/1718539249 575908_2023-02-24 14-18-05.txt/descriptors");
string? json = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/1718539249/descriptors");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetDescriptors)}.json"), json);
Result<InfinityQSDescriptorV3[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSDescriptorV3[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -146,7 +154,7 @@ public class UnitTestInfinityQSV4Controller
Result<InfinityQSV4[]>? result = infinityQSV4Repository?.GetHeader("1718539249");
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -155,13 +163,13 @@ public class UnitTestInfinityQSV4Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/1718539249/header");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeader)}.json"), json);
Result<InfinityQSV4[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<InfinityQSV4[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result?.Results[0].Part);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -173,7 +181,7 @@ public class UnitTestInfinityQSV4Controller
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
string? result = infinityQSV4Repository?.GetProductDataAverageSumOfDefectsProcessMeanProcessSigma("41", "8IN_THIN ROTR");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -182,11 +190,11 @@ public class UnitTestInfinityQSV4Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/41/product-data-average-sum-of-defects-process-mean-process-sigma?recipe=8IN_THIN ROTR");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProductDataAverageSumOfDefectsProcessMeanProcessSigma)}.json"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -199,7 +207,7 @@ public class UnitTestInfinityQSV4Controller
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
List<string[]>? results = infinityQSV4Repository?.GetEpiProTempVerificationRows(night);
Assert.IsNotNull(results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -208,11 +216,11 @@ public class UnitTestInfinityQSV4Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/epi-pro-temp-verification-rows/?night=44&night=46&night=52&night=54");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerificationRows)}.json"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -225,7 +233,7 @@ public class UnitTestInfinityQSV4Controller
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
string? result = infinityQSV4Repository?.GetEpiProTempVerification(night);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -234,11 +242,11 @@ public class UnitTestInfinityQSV4Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/epi-pro-temp-verification/?night=44&night=46&night=52&night=54");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetEpiProTempVerification)}.html"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -250,7 +258,7 @@ public class UnitTestInfinityQSV4Controller
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
List<Reactor>? results = infinityQSV4Repository?.GetReactors();
Assert.IsNotNull(results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -266,7 +274,7 @@ public class UnitTestInfinityQSV4Controller
result = infinityQSV4Repository?.GetProductionSpecification(part);
Assert.IsNotNull(result);
}
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -298,7 +306,7 @@ public class UnitTestInfinityQSV4Controller
result = infinityQSV4Repository?.GetProductionSpecification(part);
Assert.IsNotNull(result);
}
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -313,7 +321,7 @@ public class UnitTestInfinityQSV4Controller
IInfinityQSV4Repository? infinityQSV4Repository = serviceProvider?.GetRequiredService<IInfinityQSV4Repository>();
string? result = infinityQSV4Repository?.GetLastGroupIdWithValue(process, part, test);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -325,11 +333,11 @@ public class UnitTestInfinityQSV4Controller
const string process = "35";
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerVersion}/{_ControllerName}/{process}/last-group-id-with-value/?part={part}&test={test}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLastGroupIdWithValue)}.html"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -6,14 +6,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestOpenInsightV1Controller
public class UnitTestOpenInsightV1Controller : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -21,7 +21,6 @@ public class UnitTestOpenInsightV1Controller
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -35,12 +34,19 @@ public class UnitTestOpenInsightV1Controller
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IOpenInsightV1Controller<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -51,7 +57,7 @@ public class UnitTestOpenInsightV1Controller
IOpenInsightV1Repository? openInsightRepository = serviceProvider?.GetRequiredService<IOpenInsightV1Repository>();
string? result = openInsightRepository?.GetTencorRun("615071", "10/30/2023 06:48:34PM", "6IN_EPP ROTR");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -60,11 +66,11 @@ public class UnitTestOpenInsightV1Controller
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/615071/tencor-run?insert_date=10/30/2023 06:48:34PM&recipe=6IN_EPP ROTR");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetTencorRun)}.json"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}

View File

@ -7,14 +7,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestPinController
public class UnitTestPinController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -22,19 +22,32 @@ public class UnitTestPinController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.PinController)[..^10];
}
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IPinController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -47,7 +60,7 @@ public class UnitTestPinController
Assert.IsNotNull(metrologyRepository);
Result<Pinned[]>? result = pinRepository?.GetPinnedTable(metrologyRepository, id: 1, cde_id: null, biorad_id: null, rds: null);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -60,7 +73,7 @@ public class UnitTestPinController
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetPinnedTable)}.json"), json);
Result<Pinned[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<Pinned[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
}

View File

@ -7,14 +7,14 @@ using OI.Metrology.Shared.ViewModels;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestServiceShopOrderController
public class UnitTestServiceShopOrderController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -22,19 +22,32 @@ public class UnitTestServiceShopOrderController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.ServiceShopOrderController)[..^10];
}
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IServiceShopOrderController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -42,9 +55,9 @@ public class UnitTestServiceShopOrderController
{
if (_Logger is null)
throw new NullReferenceException(nameof(_Logger));
ServiceShopOrder[] serviceShopOrders = IServiceShopOrder.GetServiceShopOrders(null);
ServiceShopOrder[]? serviceShopOrders = IServiceShopOrder.GetServiceShopOrders(null);
Assert.IsNotNull(serviceShopOrders);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -54,13 +67,13 @@ public class UnitTestServiceShopOrderController
ServiceShopOrder[]? serviceShopOrders;
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IServiceShopOrderRepository? serviceShopOrderRepository = serviceProvider?.GetRequiredService<IServiceShopOrderRepository>();
Assert.IsTrue(serviceShopOrderRepository is not null);
Assert.IsNotNull(serviceShopOrderRepository);
serviceShopOrders = await serviceShopOrderRepository.GetAllServiceShopOrders();
Assert.IsTrue(serviceShopOrders is not null);
Assert.IsNotNull(serviceShopOrders);
serviceShopOrders = await serviceShopOrderRepository.GetServiceShopOrders("23188d3d-9b75-ed11-ab8b-0050568f2fc3");
Assert.IsTrue(serviceShopOrders is not null && serviceShopOrders.Length != 0);
Assert.IsNotNull(serviceShopOrders[0].ToString());
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -68,14 +81,14 @@ public class UnitTestServiceShopOrderController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string actionName = nameof(IServiceShopOrderController<object>.Action.All);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/{actionName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetAllServiceShopOrders)}.json"), json);
ServiceShopOrder[]? serviceShopOrders = System.Text.Json.JsonSerializer.Deserialize<ServiceShopOrder[]>(json);
Assert.IsNotNull(serviceShopOrders);
Assert.IsTrue(serviceShopOrders.Length != 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreNotEqual(0, serviceShopOrders.Length);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
}

View File

@ -10,14 +10,14 @@ using System.Net.Http.Json;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestToolTypesController
public class UnitTestToolTypesController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
@ -25,7 +25,6 @@ public class UnitTestToolTypesController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
@ -39,12 +38,19 @@ public class UnitTestToolTypesController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IToolTypesController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -54,12 +60,12 @@ public class UnitTestToolTypesController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
Result<ToolTypeNameId[]>? result = toolTypesRepository?.Index(metrologyRepository);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Length != 0);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsFalse(result.Results.All(l => l.ID == 0));
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -67,14 +73,14 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(Index)}.json"), json);
Result<ToolTypeNameId[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeNameId[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Length != 0);
Assert.AreNotEqual(0, result.Results.Length);
Assert.IsFalse(result.Results.All(l => l.ID == 0));
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -84,13 +90,13 @@ public class UnitTestToolTypesController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
Result<ToolTypeMetadataResult>? result = toolTypesRepository?.GetToolTypeMetadata(metrologyRepository, id: 1, sortby: string.Empty);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Metadata);
Assert.IsTrue(result.Results.Metadata.Length != 0);
Assert.AreNotEqual(0, result.Results.Metadata.Length);
Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0));
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -98,15 +104,15 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetToolTypeMetadata)}.json"), json);
Result<ToolTypeMetadataResult>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeMetadataResult>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Metadata);
Assert.IsTrue(result.Results.Metadata.Length != 0);
Assert.AreNotEqual(0, result.Results.Metadata.Length);
Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0));
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -116,11 +122,11 @@ public class UnitTestToolTypesController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
Result<DataTable>? result = toolTypesRepository?.GetHeaders(metrologyRepository, id: 1, datebegin: null, dateend: null, page: null, pagesize: null, headerid: null);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -128,13 +134,13 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaders)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -144,11 +150,12 @@ public class UnitTestToolTypesController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
Result<HeaderCommon[]>? result = toolTypesRepository?.GetHeaderTitles(metrologyRepository, id: -1, page: null, pagesize: null);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result?.Results.Length != 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(result);
Assert.IsNotNull(result.Results);
Assert.AreNotEqual(0, result.Results.Length);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -156,13 +163,13 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderTitles)}.json"), json);
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Length != 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreNotEqual(0, result.Results.Length);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -172,11 +179,11 @@ public class UnitTestToolTypesController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
Result<ColumnValue[]>? result = toolTypesRepository?.GetHeaderFields(metrologyRepository, id: 1, headerid: 1);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Length != 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreNotEqual(0, result.Results.Length);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -184,13 +191,13 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/fields");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetHeaderFields)}.json"), json);
Result<ColumnValue[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ColumnValue[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Length != 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreNotEqual(0, result.Results.Length);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -200,11 +207,11 @@ public class UnitTestToolTypesController
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(metrologyRepository);
Result<DataTable>? result = toolTypesRepository?.GetData(metrologyRepository, id: 1, headerid: 1);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[TestMethod]
@ -212,13 +219,13 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetData)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -227,19 +234,19 @@ public class UnitTestToolTypesController
{
_Logger?.LogInformation("Starting Web Application");
int toolTypeId = 1;
string tabletype = "data";
string tableType = "data";
string filename = "data.txt";
string attachmentId = "ffdf5410-ca19-4097-bfa4-b398e236d07e";
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IAttachmentsService? attachmentsService = serviceProvider?.GetRequiredService<IAttachmentsService>();
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(attachmentsService is not null);
Assert.IsTrue(metrologyRepository is not null);
Assert.IsTrue(toolTypesRepository is not null);
(string? message, string? _, Stream? _) = toolTypesRepository.GetAttachment(metrologyRepository, attachmentsService, toolTypeId, tabletype, attachmentId, filename);
Assert.IsTrue(message is null);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNotNull(attachmentsService);
Assert.IsNotNull(metrologyRepository);
Assert.IsNotNull(toolTypesRepository);
(string? message, string? _, Stream? _) = toolTypesRepository.GetAttachment(metrologyRepository, attachmentsService, toolTypeId, tableType, attachmentId, filename);
Assert.IsNull(message);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -248,9 +255,9 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/data/files/ffdf5410-ca19-4097-bfa4-b398e236d07e/data.txt");
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -263,12 +270,12 @@ public class UnitTestToolTypesController
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Server.Models.AppSettings? appSettings = serviceProvider?.GetRequiredService<Server.Models.AppSettings>();
Assert.IsTrue(appSettings is not null);
Assert.IsTrue(attachmentsService is not null);
Assert.IsTrue(metrologyRepository is not null);
Assert.IsNotNull(appSettings);
Assert.IsNotNull(attachmentsService);
Assert.IsNotNull(metrologyRepository);
string? message = toolTypesRepository?.OIExport(metrologyRepository, attachmentsService, toolTypeId: 1, headerid: 1);
Assert.IsTrue(message is null);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.IsNull(message);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
[Ignore]
@ -277,9 +284,9 @@ public class UnitTestToolTypesController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/headers/1/export");
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
}
}

View File

@ -7,14 +7,14 @@ using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestWaferCounterController
public class UnitTestWaferCounterController : BaseTestClass
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static string? _TestContextTestName;
public TestContext TestContext { get; set; }
private static WebApplicationFactory<Wafer.Counter.Program>? _WebApplicationFactory;
#pragma warning restore
@ -22,7 +22,6 @@ public class UnitTestWaferCounterController
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContextTestName = testContext.TestName;
_WebApplicationFactory = new WebApplicationFactory<Wafer.Counter.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Wafer.Counter.Program>>();
@ -36,12 +35,19 @@ public class UnitTestWaferCounterController
catch (Exception) { }
}
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
IncrementFailedTests();
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IFileShareController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
Assert.AreEqual(IWaferCounterController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -54,7 +60,7 @@ public class UnitTestWaferCounterController
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
WaferCounter? result = waferCounterRepository?.GetLastQuantityAndSlotMap(area: "FQA", waferSize: "8INCH", text: "Test");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}
@ -64,10 +70,10 @@ public class UnitTestWaferCounterController
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
Assert.IsNotNull(httpClient);
string? response = await httpClient.GetStringAsync($"api/v1/{_ControllerName}/FQA/last-quantity-and-slot-map/?waferSize=8INCH&text=Test");
Assert.IsNotNull(response);
_Logger?.LogInformation("{TestName} completed", _TestContextTestName);
_Logger?.LogInformation("{TestName} completed", TestContext.TestName);
NonThrowTryCatch();
}