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<Server.Program> _WebApplicationFactory;

#pragma warning restore

    [ClassInitialize]
    public static void ClassInitAsync(TestContext testContext)
    {
        _TestContext = testContext;
        _Logger = Log.ForContext<UnitInboundController>();
        _WebApplicationFactory = new WebApplicationFactory<Server.Program>();
        _ControllerName = nameof(Server.ApiControllers.InboundController)[..^10];
    }

    [TestMethod]
    public void TestControllerName()
    {
        _Logger.Information("Starting Web Application");
        Assert.AreEqual(IInboundController<string>.GetRouteName(), _ControllerName);
        _Logger.Information($"{_TestContext?.TestName} completed");
    }

    [TestMethod]
    [Ignore]
    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");
    }

    [TestMethod]
    [Ignore]
    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");
    }

}