oi-metrology/Tests/UnitInboundController.cs
2023-01-09 10:04:58 -07:00

57 lines
1.7 KiB
C#

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<Viewer.Program> _WebApplicationFactory;
#pragma warning restore
[ClassInitialize]
public static void ClassInitAsync(TestContext testContext)
{
_TestContext = testContext;
_Logger = Log.ForContext<UnitInboundController>();
_WebApplicationFactory = new WebApplicationFactory<Viewer.Program>();
_ControllerName = nameof(Viewer.ApiControllers.ToolTypesController)[..^10];
}
[TestMethod]
public void TestControllerName()
{
_Logger.Information("Starting Web Application");
Assert.AreEqual(IToolTypesController<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");
}
}