- 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:
@ -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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user