Host from Windows

This commit is contained in:
2024-06-17 17:11:36 -07:00
parent 6737ddfb59
commit da3e839a48
36 changed files with 1918 additions and 667 deletions

View File

@ -1,3 +1,6 @@
{
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/**"
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/**",
"cSpell.words": [
"datebegin"
]
}

View File

@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
using System.Data;
using System.Text;
namespace OI.Metrology.Tests;
@ -202,4 +203,61 @@ public class UnitTestExportController
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public void GetExportData()
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Assert.IsTrue(metrologyRepository is not null);
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", _TestContext?.TestName);
}
[Ignore]
[TestMethod]
public async Task GetExportDataApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
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", _TestContext?.TestName);
}
[Ignore]
[TestMethod]
public void GetCSVExport()
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Assert.IsTrue(metrologyRepository is not null);
string? result = exportRepository?.GetCSVExport(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
// [Ignore]
[TestMethod]
public async Task GetCSVExportDat()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
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", _TestContext?.TestName);
}
}

View File

@ -221,36 +221,6 @@ public class UnitTestToolTypesController
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
[Ignore]
[TestMethod]
public void GetExportData()
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository? toolTypesRepository = serviceProvider?.GetRequiredService<IToolTypesRepository>();
Assert.IsTrue(metrologyRepository is not null);
Result<DataTable>? result = toolTypesRepository?.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
[Ignore]
[TestMethod]
public async Task GetExportDataApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/export");
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", _TestContext?.TestName);
}
[Ignore]
[TestMethod]
public void GetAttachment()

View File

@ -1,119 +0,0 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestWaferCounterController
{
#pragma warning disable CS8618
private static ILogger? _Logger;
private static string _ControllerName;
private static TestContext _TestContext;
private static WebApplicationFactory<Server.Program>? _WebApplicationFactory;
#pragma warning restore
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContext = testContext;
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
_Logger = serviceProvider.GetRequiredService<ILogger<Server.Program>>();
_ControllerName = nameof(Server.ApiControllers.WaferCounterController)[..^10];
}
private static void NonThrowTryCatch()
{
try
{ throw new Exception(); }
catch (Exception) { }
}
[TestMethod]
public void TestControllerName()
{
_Logger?.LogInformation("Starting Web Application");
Assert.AreEqual(IWaferCounterController<string>.GetRouteName(), _ControllerName);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[TestMethod]
public void GetSlotMap()
{
_Logger?.LogInformation("Starting Web Application");
string? result;
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
result = waferCounterRepository?.GetSlotMap("T00", "P0000000");
Assert.AreEqual("0000000000000000000000000", result);
result = waferCounterRepository?.GetSlotMap("T25", "P1FFFFFF");
Assert.AreEqual("1111111111111111111111111", result);
result = waferCounterRepository?.GetSlotMap("T12", "P0AAAAAA");
Assert.AreEqual("0101010101010101010101010", result);
result = waferCounterRepository?.GetSlotMap("T13", "P1555555");
Assert.AreEqual("1010101010101010101010101", result);
result = waferCounterRepository?.GetSlotMap("T20", "P0EFFFF8");
Assert.AreEqual("0111011111111111111111000", result);
result = waferCounterRepository?.GetSlotMap("T20", "P07FFFF8");
Assert.AreEqual("0011111111111111111111000", result);
result = waferCounterRepository?.GetSlotMap("T20", "P17FFFF0");
Assert.AreEqual("1011111111111111111110000", result);
result = waferCounterRepository?.GetSlotMap("T03", "P1002002");
Assert.AreEqual("1000000000010000000000010", result);
result = waferCounterRepository?.GetSlotMap("T02", "P1000002");
Assert.AreEqual("1000000000000000000000010", result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public void GetLastQuantityAndSlotMap()
{
WaferCounter? result;
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IWaferCounterRepository? waferCounterRepository = serviceProvider?.GetRequiredService<IWaferCounterRepository>();
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-East", "8INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-West", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("EPP-West", "8INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("FQA", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("FQA", "8INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("MU", "6INCH");
Assert.IsNotNull(result);
result = waferCounterRepository?.GetLastQuantityAndSlotMap("MU", "8INCH");
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public async Task GetLastQuantityAndSlotMapApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/8INCH/last-quantity-and-slot-map/?area=EPP-East");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLastQuantityAndSlotMap)}.json"), json);
Assert.IsNotNull(json);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
NonThrowTryCatch();
}
}