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

@ -43,13 +43,13 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" />
<ProjectReference Include="..\Viewer\OI.Metrology.Viewer.csproj" />
<ProjectReference Include="..\Server\OI.Metrology.Server.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\Viewer\appsettings.json">
<None Include="..\Server\appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Viewer\appsettings.Development.json">
<None Include="..\Server\appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\.Data\RdsMaxRepo.json">

View File

@ -16,7 +16,7 @@ public class UnitAwaitingDispoController
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
@ -25,8 +25,8 @@ public class UnitAwaitingDispoController
{
_TestContext = testContext;
_Logger = Log.ForContext<UnitAwaitingDispoController>();
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
_ControllerName = nameof(Viewer.ApiControllers.AwaitingDispoController)[..^10];
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.AwaitingDispoController)[..^10];
}
[TestMethod]

View File

@ -13,7 +13,7 @@ public class UnitInboundController
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
@ -22,8 +22,8 @@ public class UnitInboundController
{
_TestContext = testContext;
_Logger = Log.ForContext<UnitInboundController>();
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
_ControllerName = nameof(Viewer.ApiControllers.InboundController)[..^10];
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.InboundController)[..^10];
}
[TestMethod]

View File

@ -15,7 +15,7 @@ public class UnitTestAppSettingsController
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
@ -24,8 +24,8 @@ public class UnitTestAppSettingsController
{
_TestContext = testContext;
_Logger = Log.ForContext<UnitTestAppSettingsController>();
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
_ControllerName = nameof(Viewer.ApiControllers.AppSettingsController)[..^10];
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10];
}
[TestMethod]
@ -41,7 +41,7 @@ public class UnitTestAppSettingsController
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
Viewer.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Viewer.Models.AppSettings>();
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Server.Models.AppSettings>();
Assert.IsNotNull(appSettings);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -66,10 +66,11 @@ public class UnitTestAppSettingsController
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 result = await httpResponseMessage.Content.ReadAsStringAsync();
string json = await httpResponseMessage.Content.ReadAsStringAsync();
httpClient.Dispose();
Assert.IsNotNull(result);
Assert.IsTrue(result != "[]");
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -93,9 +94,10 @@ public class UnitTestAppSettingsController
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 result = await httpResponseMessage.Content.ReadAsStringAsync();
string json = await httpResponseMessage.Content.ReadAsStringAsync();
httpClient.Dispose();
Assert.IsNotNull(result);
Assert.IsNotNull(json);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}

View File

@ -15,7 +15,7 @@ public class UnitTestClientSettingsController
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
@ -24,8 +24,8 @@ public class UnitTestClientSettingsController
{
_TestContext = testContext;
_Logger = Log.ForContext<UnitTestClientSettingsController>();
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
_ControllerName = nameof(Viewer.ApiControllers.ClientSettingsController)[..^10];
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.ClientSettingsController)[..^10];
}
[TestMethod]
@ -56,10 +56,11 @@ public class UnitTestClientSettingsController
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 result = await httpResponseMessage.Content.ReadAsStringAsync();
string json = await httpResponseMessage.Content.ReadAsStringAsync();
httpClient.Dispose();
Assert.IsNotNull(result);
Assert.IsTrue(result != "[]");
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
@ -83,9 +84,10 @@ public class UnitTestClientSettingsController
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 result = await httpResponseMessage.Content.ReadAsStringAsync();
string json = await httpResponseMessage.Content.ReadAsStringAsync();
httpClient.Dispose();
Assert.IsNotNull(result);
Assert.IsNotNull(json);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}

View File

@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.ViewModels;
using Serilog;
using System.Net.Http.Json;
namespace OI.Metrology.Tests;
@ -16,7 +15,7 @@ public class UnitTestServiceShopOrderController
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
@ -25,8 +24,8 @@ public class UnitTestServiceShopOrderController
{
_TestContext = testContext;
_Logger = Log.ForContext<UnitTestServiceShopOrderController>();
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
_ControllerName = nameof(Viewer.ApiControllers.ServiceShopOrderController)[..^10];
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.ServiceShopOrderController)[..^10];
}
[TestMethod]
@ -68,9 +67,11 @@ public class UnitTestServiceShopOrderController
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(IServiceShopOrderController<object>.Action.All);
ServiceShopOrder[]? serviceShopOrders = await httpClient.GetFromJsonAsync<ServiceShopOrder[]>($"api/{_ControllerName}/{actionName}");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/{actionName}");
ServiceShopOrder[]? serviceShopOrders = System.Text.Json.JsonSerializer.Deserialize<ServiceShopOrder[]>(json);
Assert.IsNotNull(serviceShopOrders);
Assert.IsTrue(serviceShopOrders.Any());
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_TestContext.ManagedMethod}.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}

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