git checkout -b feature-branch

This commit is contained in:
2023-01-13 18:13:01 -07:00
parent 0468c8d42d
commit c292328abe
855 changed files with 61144 additions and 112 deletions

View File

@ -18,7 +18,7 @@ public class UnitTestToolTypesController
private static ILogger _Logger;
private static string _ControllerName;
private static TestContext _TestContext;
private static WebApplicationFactory<Viewer.Program> _WebApplicationFactory;
private static WebApplicationFactory<Server.Program> _WebApplicationFactory;
#pragma warning restore
@ -27,8 +27,8 @@ public class UnitTestToolTypesController
{
_TestContext = testContext;
_Logger = Log.ForContext<UnitTestToolTypesController>();
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
_ControllerName = nameof(Viewer.ApiControllers.ToolTypesController)[..^10];
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.ToolTypesController)[..^10];
}
[TestMethod]
@ -58,10 +58,12 @@ public class UnitTestToolTypesController
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
Result<ToolTypeNameId[]>? result = await httpClient.GetFromJsonAsync<Result<ToolTypeNameId[]>>($"api/{_ControllerName}");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
Result<ToolTypeNameId[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ToolTypeNameId[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
Assert.IsFalse(result.Results.All(l => l.ID == 0));
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -85,11 +87,13 @@ public class UnitTestToolTypesController
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
Result<ToolTypeMetadataResult>? result = await httpClient.GetFromJsonAsync<Result<ToolTypeMetadataResult>>($"api/{_ControllerName}/1");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1");
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.Any());
Assert.IsFalse(result.Results.Metadata.All(l => l.ToolTypeID == 0));
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -115,6 +119,7 @@ public class UnitTestToolTypesController
Result<DataTable>? result = System.Text.Json.JsonSerializer.Deserialize<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -136,9 +141,11 @@ public class UnitTestToolTypesController
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
Result<HeaderCommon[]>? result = await httpClient.GetFromJsonAsync<Result<HeaderCommon[]>>($"api/{_ControllerName}/1/headertitles");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headertitles");
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -160,9 +167,11 @@ public class UnitTestToolTypesController
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
Result<ColumnValue[]>? result = await httpClient.GetFromJsonAsync<Result<ColumnValue[]>>($"api/{_ControllerName}/1/headers/1/fields");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/fields");
Result<ColumnValue[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ColumnValue[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -188,6 +197,7 @@ public class UnitTestToolTypesController
Result<DataTable>? result = System.Text.Json.JsonSerializer.Deserialize<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -227,7 +237,7 @@ public class UnitTestToolTypesController
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Viewer.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Viewer.Models.AppSettings>();
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Server.Models.AppSettings>();
Exception? exception = toolTypesRepository.OIExport(metrologyRepository, appSettings.OIExportPath, toolTypeId: 1, headerid: 1);
Assert.IsTrue(exception is null);
_Logger.Information($"{_TestContext?.TestName} completed");