using Microsoft.AspNetCore.Mvc.Testing; using OI.Metrology.Shared.Models.Stateless; using Serilog; namespace OI.Metrology.Tests; [TestClass] public class UnitInboundController { #pragma warning disable CS8618 private static ILogger _Logger; private static string _ControllerName; private static TestContext _TestContext; private static WebApplicationFactory _WebApplicationFactory; #pragma warning restore [ClassInitialize] public static void ClassInitAsync(TestContext testContext) { _TestContext = testContext; _Logger = Log.ForContext(); _WebApplicationFactory = new WebApplicationFactory(); _ControllerName = nameof(Server.ApiControllers.InboundController)[..^10]; } [TestMethod] public void TestControllerName() { _Logger.Information("Starting Web Application"); Assert.AreEqual(IInboundController.GetRouteName(), _ControllerName); _Logger.Information($"{_TestContext?.TestName} completed"); } [Ignore] [TestMethod] public async Task DataApi() { HttpClient httpClient = _WebApplicationFactory.CreateClient(); _Logger.Information("Starting Web Application"); _ = await httpClient.PostAsync($"api/{_ControllerName}/a", null); _Logger.Information($"{_TestContext?.TestName} completed"); } [Ignore] [TestMethod] public async Task AttachFileApi() { HttpClient httpClient = _WebApplicationFactory.CreateClient(); _Logger.Information("Starting Web Application"); _ = await httpClient.PostAsync($"api/{_ControllerName}/a/attachment", null); _Logger.Information($"{_TestContext?.TestName} completed"); } }