- 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

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);
}
}