Viewer to Server

This commit is contained in:
2023-02-16 15:17:31 -07:00
parent 5c50078c04
commit a25dc93610
968 changed files with 16395 additions and 2385 deletions

3
Tests/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"coverage-gutters.coverageBaseDir": "../.vscode/TestResults/**"
}

View File

@ -58,7 +58,9 @@ public class AppSettings
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
{
Models.AppSettings result;
AppSettings appSettings = configurationRoot.Get<AppSettings>();
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
if (appSettings is null)
throw new NullReferenceException(nameof(appSettings));
result = Get(appSettings);
return result;
}

View File

@ -5,7 +5,7 @@
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<VSTestLogger>trx</VSTestLogger>
@ -27,27 +27,29 @@
<DefineConstants>Linux</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\Archive\Archive.csproj" />
<ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" />
<ProjectReference Include="..\Server\OI.Metrology.Server.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\Archive\appsettings.json">
<None Include="..\Server\appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Archive\appsettings.Development.json">
<None Include="..\Server\appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\.Data\RdsMaxRepo.json">

View File

@ -0,0 +1,104 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Net.Http.Json;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitAwaitingDispoController
{
#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<UnitAwaitingDispoController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.AwaitingDispoController)[..^10];
}
[TestMethod]
public void TestControllerName()
{
_Logger.Information("Starting Web Application");
Assert.AreEqual(IAwaitingDispoController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void Index()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IEnumerable<AwaitingDisposition> awaitingDispositions = metrologyRepository.GetAwaitingDisposition();
Assert.IsTrue(awaitingDispositions is not null);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task IndexApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(IMetrologyRepository.GetAwaitingDisposition)}Api.json"), json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
[Ignore]
public void MarkAsReviewed()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
_ = metrologyRepository.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: false);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
[Ignore]
public async Task MarkAsReviewedApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/markasreviewed");
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
[Ignore]
public void MarkAsAwaiting()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
int dateCleared = metrologyRepository.UpdateReviewDate(toolTypeId: 1, headerId: 1, clearDate: true);
Assert.IsTrue(dateCleared <= 1);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
[Ignore]
public async Task MarkAsAwaitingApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
_ = await httpClient.PostAsync($"api/{_ControllerName}/markasawaiting", null);
_Logger.Information($"{_TestContext?.TestName} completed");
}
}

View File

@ -0,0 +1,57 @@
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");
}
}

View File

@ -0,0 +1,102 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Net;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestAppSettingsController
{
#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<UnitTestAppSettingsController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.AppSettingsController)[..^10];
}
[TestMethod]
public void TestControllerName()
{
_Logger.Information("Starting Web Application");
Assert.AreEqual(IAppSettingsController<object>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void AppSettings()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
Server.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Server.Models.AppSettings>();
Assert.IsNotNull(appSettings);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetAppSettings()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings> appSettingsRepository = serviceProvider.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
Server.Models.Binder.AppSettings appSettings = appSettingsRepository.GetAppSettings();
Assert.IsTrue(appSettings is not null);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetAppSettingsApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(IAppSettingsController<object>.Action.App);
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 json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetAppSettingsApi)}.json"), json);
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetBuildNumberAndGitCommitSeven()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IAppSettingsRepository<Server.Models.Binder.AppSettings> appSettingsRepository = serviceProvider.GetRequiredService<IAppSettingsRepository<Server.Models.Binder.AppSettings>>();
string result = appSettingsRepository.GetBuildNumberAndGitCommitSeven();
Assert.IsTrue(result is not null);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetBuildNumberAndGitCommitSevenApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(IAppSettingsController<object>.Action.DevOps);
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 json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetBuildNumberAndGitCommitSevenApi)}.json"), json);
Assert.IsNotNull(json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
}

View File

@ -1,87 +1,87 @@
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Archive.Repositories;
using OI.Metrology.Shared.Models;
using OI.Metrology.Shared.Repositories;
using OI.Metrology.Tests.Models;
using Serilog;
using System.Reflection;
using System.Text.Json;
// using Microsoft.Extensions.Caching.Memory;
// using Microsoft.Extensions.Configuration;
// using Microsoft.Extensions.DependencyInjection;
// using OI.Metrology.Archive.Repositories;
// using OI.Metrology.Shared.Models;
// using OI.Metrology.Shared.Repositories;
// using OI.Metrology.Tests.Models;
// using Serilog;
// using System.Reflection;
// using System.Text.Json;
namespace OI.Metrology.Tests;
// namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestArchive
{
// [TestClass]
// public class UnitTestArchive
// {
private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly IMemoryCache? _MemoryCache;
private readonly IConfigurationRoot _ConfigurationRoot;
// private readonly ILogger _Logger;
// private readonly AppSettings _AppSettings;
// private readonly string _WorkingDirectory;
// private readonly IMemoryCache? _MemoryCache;
// private readonly IConfigurationRoot _ConfigurationRoot;
public UnitTestArchive()
{
ILogger logger;
AppSettings appSettings;
string workingDirectory;
IConfigurationRoot configurationRoot;
LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile("appsettings.Development.json");
configurationRoot = configurationBuilder.Build();
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
Log.Logger = loggerConfiguration.CreateLogger();
logger = Log.ForContext<UnitTestArchive>();
logger.Information("Complete");
ServiceCollection services = new();
ServiceProvider serviceProvider = services.BuildServiceProvider();
_ = services.AddMemoryCache();
_MemoryCache = serviceProvider.GetService<IMemoryCache>();
_Logger = logger;
_AppSettings = appSettings;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
}
// public UnitTestArchive()
// {
// ILogger logger;
// AppSettings appSettings;
// string workingDirectory;
// IConfigurationRoot configurationRoot;
// LoggerConfiguration loggerConfiguration = new();
// Assembly assembly = Assembly.GetExecutingAssembly();
// IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
// .AddEnvironmentVariables()
// .AddJsonFile("appsettings.Development.json");
// configurationRoot = configurationBuilder.Build();
// appSettings = Models.Binder.AppSettings.Get(configurationRoot);
// workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
// Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
// _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
// Log.Logger = loggerConfiguration.CreateLogger();
// logger = Log.ForContext<UnitTestArchive>();
// logger.Information("Complete");
// ServiceCollection services = new();
// ServiceProvider serviceProvider = services.BuildServiceProvider();
// _ = services.AddMemoryCache();
// _MemoryCache = serviceProvider.GetService<IMemoryCache>();
// _Logger = logger;
// _AppSettings = appSettings;
// _WorkingDirectory = workingDirectory;
// _ConfigurationRoot = configurationRoot;
// }
[TestMethod]
public void TestMethodNull()
{
Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_WorkingDirectory is null);
Assert.IsFalse(_ConfigurationRoot is null);
}
// [TestMethod]
// public void TestMethodNull()
// {
// Assert.IsFalse(_Logger is null);
// Assert.IsFalse(_AppSettings is null);
// Assert.IsFalse(_WorkingDirectory is null);
// Assert.IsFalse(_ConfigurationRoot is null);
// }
[TestMethod]
public void TestMethodArchive()
{
Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_WorkingDirectory is null);
Assert.IsFalse(_ConfigurationRoot is null);
}
// [TestMethod]
// public void TestMethodArchive()
// {
// Assert.IsFalse(_Logger is null);
// Assert.IsFalse(_AppSettings is null);
// Assert.IsFalse(_WorkingDirectory is null);
// Assert.IsFalse(_ConfigurationRoot is null);
// }
[TestMethod]
public void TestMethodArchiveJson()
{
string json;
string jsonFile = Path.Combine(AppContext.BaseDirectory, "RdsMaxRepo.json");
Assert.IsTrue(File.Exists(jsonFile));
json = JsonSerializer.Serialize(_AppSettings);
IRdsMaxRepo rdsMaxRepo = new RdsMaxRepo(json, _MemoryCache);
json = File.ReadAllText(jsonFile);
Shared.DataModels.RDS.Max[]? collection = JsonSerializer.Deserialize<Shared.DataModels.RDS.Max[]>(json);
if (collection is null)
throw new NullReferenceException(nameof(collection));
List<string[]> data = rdsMaxRepo.Convert(collection);
Assert.IsTrue(data.Any());
}
// [TestMethod]
// public void TestMethodArchiveJson()
// {
// string json;
// string jsonFile = Path.Combine(AppContext.BaseDirectory, "RdsMaxRepo.json");
// Assert.IsTrue(File.Exists(jsonFile));
// json = JsonSerializer.Serialize(_AppSettings);
// IRdsMaxRepo rdsMaxRepo = new RdsMaxRepo(json, _MemoryCache);
// json = File.ReadAllText(jsonFile);
// Shared.DataModels.RDS.Max[]? collection = JsonSerializer.Deserialize<Shared.DataModels.RDS.Max[]>(json);
// if (collection is null)
// throw new NullReferenceException(nameof(collection));
// List<string[]> data = rdsMaxRepo.Convert(collection);
// Assert.IsTrue(data.Any());
// }
}
// }

View File

@ -0,0 +1,92 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Shared.Models.Stateless;
using Serilog;
using System.Net;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestClientSettingsController
{
#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<UnitTestClientSettingsController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.ClientSettingsController)[..^10];
}
[TestMethod]
public void TestControllerName()
{
_Logger.Information("Starting Web Application");
Assert.AreEqual(IClientSettingsController<object>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetClientSettings()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IClientSettingsRepository clientSettingsRepository = serviceProvider.GetRequiredService<IClientSettingsRepository>();
List<string> clientSettings = clientSettingsRepository.GetClientSettings(null);
Assert.IsTrue(clientSettings is not null);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetClientSettingsApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(IClientSettingsController<object>.Action.Client);
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 json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetClientSettingsApi)}.json"), json);
Assert.IsNotNull(json);
Assert.IsTrue(json != "[]");
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetIpAddress()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IClientSettingsRepository clientSettingsRepository = serviceProvider.GetRequiredService<IClientSettingsRepository>();
string? ipAddress = clientSettingsRepository.GetIpAddress(null);
Assert.IsTrue(ipAddress is not null);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetIpAddressApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(IClientSettingsController<object>.Action.IP);
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 json = await httpResponseMessage.Content.ReadAsStringAsync();
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetIpAddressApi)}.json"), json);
Assert.IsNotNull(json);
_Logger.Information($"{_TestContext?.TestName} completed");
}
}

View File

@ -1,52 +0,0 @@
using Microsoft.Extensions.Configuration;
using OI.Metrology.Shared.Models;
using OI.Metrology.Tests.Models;
using Serilog;
using System.Reflection;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestExample
{
private readonly ILogger _Logger;
private readonly AppSettings _AppSettings;
private readonly string _WorkingDirectory;
private readonly IConfigurationRoot _ConfigurationRoot;
public UnitTestExample()
{
ILogger logger;
AppSettings appSettings;
string workingDirectory;
IConfigurationRoot configurationRoot;
LoggerConfiguration loggerConfiguration = new();
Assembly assembly = Assembly.GetExecutingAssembly();
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile("appsettings.Development.json");
configurationRoot = configurationBuilder.Build();
appSettings = OI.Metrology.Tests.Models.Binder.AppSettings.Get(configurationRoot);
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
Log.Logger = loggerConfiguration.CreateLogger();
logger = Log.ForContext<UnitTestExample>();
logger.Information("Complete");
_Logger = logger;
_AppSettings = appSettings;
_WorkingDirectory = workingDirectory;
_ConfigurationRoot = configurationRoot;
}
[TestMethod]
public void TestMethodNull()
{
Assert.IsFalse(_Logger is null);
Assert.IsFalse(_AppSettings is null);
Assert.IsFalse(_WorkingDirectory is null);
Assert.IsFalse(_ConfigurationRoot is null);
}
}

View File

@ -0,0 +1,63 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
using Serilog;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestPinController
{
#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<UnitTestPinController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.PinController)[..^10];
}
[TestMethod]
public void TestControllerName()
{
_Logger.Information("Starting Web Application");
Assert.AreEqual(IPinController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetPinnedTable()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>();
Result<Pinned[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, cde_id: null, biorad_id: null, rds: null);
Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetPinnedTableApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/pinned");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetPinnedTableApi)}.json"), json);
Result<Pinned[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<Pinned[]>>(json);
Assert.IsNotNull(result?.Results);
_Logger.Information($"{_TestContext?.TestName} completed");
}
}

View File

@ -0,0 +1,109 @@
// using Microsoft.AspNetCore.Mvc.Testing;
// using Microsoft.Extensions.DependencyInjection;
// using Serilog;
// using System.Net;
// namespace OI.Metrology.Tests;
// [TestClass]
// public class UnitTestReactorController
// {
// private static TestContext? _TestContext;
// private static WebApplicationFactory<Archive.Program>? _WebApplicationFactory;
// [ClassInitialize]
// public static void ClassInitAsync(TestContext testContext)
// {
// _TestContext = testContext;
// _WebApplicationFactory = new WebApplicationFactory<Archive.Program>();
// }
// [TestMethod]
// public async Task GetReactors_ShouldReturnAllReactorsAsync()
// {
// HttpResponseMessage httpResponseMessage;
// if (_WebApplicationFactory is null)
// throw new NullReferenceException(nameof(_WebApplicationFactory));
// HttpClient httpClient = _WebApplicationFactory.CreateClient();
// ILogger log = Log.ForContext<UnitTestReactorController>();
// log.Information("Starting Web Application");
// IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
// Archive.Models.AppSettings appSettings = serviceProvider.GetRequiredService<Archive.Models.AppSettings>();
// httpResponseMessage = await httpClient.GetAsync($"api/{nameof(Archive.ApiControllers.ReactorsController)[..^10]}/true");
// Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
// Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
// httpResponseMessage = await httpClient.GetAsync($"api/{nameof(Archive.ApiControllers.ReactorsController)[..^10]}/false");
// Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
// // string result = await httpResponseMessage.Content.ReadAsStringAsync();
// // Assert.AreEqual("\"Sample Name 1\"", result);
// httpClient.Dispose();
// log.Information($"{_TestContext?.TestName} completed");
// }
// // [TestMethod]
// // public void GetAllProducts_ShouldReturnAllProducts()
// // {
// // var testProducts = GetTestProducts();
// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts);
// // var result = controller.GetAllProducts() as List<Product>;
// // Assert.AreEqual(testProducts.Count, result.Count);
// // }
// // [TestMethod]
// // public async Task GetAllProductsAsync_ShouldReturnAllProducts()
// // {
// // var testProducts = GetTestProducts();
// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts);
// // var result = await controller.GetAllProductsAsync() as List<Product>;
// // Assert.AreEqual(testProducts.Count, result.Count);
// // }
// // [TestMethod]
// // public void GetProduct_ShouldReturnCorrectProduct()
// // {
// // var testProducts = GetTestProducts();
// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts);
// // var result = controller.GetProduct(4) as OkNegotiatedContentResult<Product>;
// // Assert.IsNotNull(result);
// // Assert.AreEqual(testProducts[3].Name, result.Content.Name);
// // }
// // [TestMethod]
// // public async Task GetProductAsync_ShouldReturnCorrectProduct()
// // {
// // var testProducts = GetTestProducts();
// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(testProducts);
// // var result = await controller.GetProductAsync(4) as OkNegotiatedContentResult<Product>;
// // Assert.IsNotNull(result);
// // Assert.AreEqual(testProducts[3].Name, result.Content.Name);
// // }
// // [TestMethod]
// // public void GetProduct_ShouldNotFindProduct()
// // {
// // var controller = new OI.Metrology.Archive.ApiControllers.ReactorsController(GetTestProducts());
// // var result = controller.GetProduct(999);
// // Assert.IsInstanceOfType(result, typeof(NotFoundResult));
// // }
// // private List<Product> GetTestProducts()
// // {
// // var testProducts = new List<Product>();
// // testProducts.Add(new Product { Id = 1, Name = "Demo1", Price = 1 });
// // testProducts.Add(new Product { Id = 2, Name = "Demo2", Price = 3.75M });
// // testProducts.Add(new Product { Id = 3, Name = "Demo3", Price = 16.99M });
// // testProducts.Add(new Product { Id = 4, Name = "Demo4", Price = 11.00M });
// // return testProducts;
// // }
// [ClassCleanup]
// public static void ClassCleanup() => _WebApplicationFactory?.Dispose();
// }

View File

@ -0,0 +1,78 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.ViewModels;
using Serilog;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestServiceShopOrderController
{
#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<UnitTestServiceShopOrderController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.ServiceShopOrderController)[..^10];
}
[TestMethod]
public void TestControllerName()
{
_Logger.Information("Starting Web Application");
Assert.AreEqual(IServiceShopOrderController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetServiceShopOrders()
{
if (_Logger is null)
throw new NullReferenceException(nameof(_Logger));
ServiceShopOrder[] serviceShopOrders = IServiceShopOrder.GetServiceShopOrders(null);
Assert.IsNotNull(serviceShopOrders);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetAllServiceShopOrders()
{
_Logger.Information("Starting Web Application");
ServiceShopOrder[] serviceShopOrders;
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IServiceShopOrderRepository serviceShopOrderRepository = serviceProvider.GetRequiredService<IServiceShopOrderRepository>();
serviceShopOrders = await serviceShopOrderRepository.GetAllServiceShopOrders();
Assert.IsTrue(serviceShopOrders is not null);
serviceShopOrders = await serviceShopOrderRepository.GetServiceShopOrders("23188d3d-9b75-ed11-ab8b-0050568f2fc3");
Assert.IsTrue(serviceShopOrders is not null && serviceShopOrders.Any());
Assert.IsNotNull(serviceShopOrders[0].ToString());
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetAllServiceShopOrdersApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(IServiceShopOrderController<object>.Action.All);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/{actionName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetAllServiceShopOrdersApi)}.json"), json);
ServiceShopOrder[]? serviceShopOrders = System.Text.Json.JsonSerializer.Deserialize<ServiceShopOrder[]>(json);
Assert.IsNotNull(serviceShopOrders);
Assert.IsTrue(serviceShopOrders.Any());
_Logger.Information($"{_TestContext?.TestName} completed");
}
}

View File

@ -0,0 +1,282 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
using OI.Metrology.Shared.Services;
using Serilog;
using System.Data;
using System.Net.Http.Json;
namespace OI.Metrology.Tests;
[TestClass]
public class UnitTestToolTypesController
{
#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<UnitTestToolTypesController>();
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
_ControllerName = nameof(Server.ApiControllers.ToolTypesController)[..^10];
}
[TestMethod]
public void TestControllerName()
{
_Logger.Information("Starting Web Application");
Assert.AreEqual(IToolTypesController<string>.GetRouteName(), _ControllerName);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void Index()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Result<ToolTypeNameId[]> result = toolTypesRepository.Index(metrologyRepository);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
Assert.IsFalse(result.Results.All(l => l.ID == 0));
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task IndexApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(IndexApi)}.json"), json);
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));
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetToolTypeMetadata()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Result<ToolTypeMetadataResult> result = toolTypesRepository.GetToolTypeMetadata(metrologyRepository, id: 1, sortby: string.Empty);
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));
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetToolTypeMetadataApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetToolTypeMetadataApi)}.json"), json);
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));
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetHeaders()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Result<DataTable> result = toolTypesRepository.GetHeaders(metrologyRepository, id: 1, datebegin: null, dateend: null, page: null, pagesize: null, headerid: null);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetHeadersApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeadersApi)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetHeaderTitles()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Result<HeaderCommon[]> result = toolTypesRepository.GetHeaderTitles(metrologyRepository, id: -1, page: null, pagesize: null);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetHeaderTitlesApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeaderTitlesApi)}.json"), json);
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetHeaderFields()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Result<ColumnValue[]> result = toolTypesRepository.GetHeaderFields(metrologyRepository, id: 1, headerid: 1);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetHeaderFieldsApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/fields");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeaderFieldsApi)}.json"), json);
Result<ColumnValue[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<ColumnValue[]>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any());
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetData()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Result<DataTable> result = toolTypesRepository.GetData(metrologyRepository, id: 1, headerid: 1);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetDataApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/headers/1/data");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetDataApi)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public void GetExportData()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
Result<DataTable> result = toolTypesRepository.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
public async Task GetExportDataApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/export");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetExportDataApi)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
[Ignore]
public void GetAttachment()
{
_Logger.Information("Starting Web Application");
int toolTypeId = 1;
string tabletype = "data";
string filename = "data.txt";
string attachmentId = "ffdf5410-ca19-4097-bfa4-b398e236d07e";
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IAttachmentsService attachmentsService = serviceProvider.GetRequiredService<IAttachmentsService>();
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
(string? message, string? _, Stream? _) = toolTypesRepository.GetAttachment(metrologyRepository, attachmentsService, toolTypeId, tabletype, attachmentId, filename);
Assert.IsTrue(message is null);
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
[Ignore]
public async Task GetAttachmentApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/data/files/ffdf5410-ca19-4097-bfa4-b398e236d07e/data.txt");
_Logger.Information($"{_TestContext?.TestName} completed");
}
[TestMethod]
[Ignore]
public void OIExport()
{
_Logger.Information("Starting Web Application");
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
IToolTypesRepository toolTypesRepository = serviceProvider.GetRequiredService<IToolTypesRepository>();
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");
}
[TestMethod]
[Ignore]
public async Task OIExportApi()
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
_ = await httpClient.GetFromJsonAsync<object>($"api/{_ControllerName}/1/headers/1/oiexport");
_Logger.Information($"{_TestContext?.TestName} completed");
}
}