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

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