Host from Windows

This commit is contained in:
2024-06-17 17:11:36 -07:00
parent 6737ddfb59
commit da3e839a48
36 changed files with 1918 additions and 667 deletions

View File

@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless;
using System.Data;
using System.Text;
namespace OI.Metrology.Tests;
@ -202,4 +203,61 @@ public class UnitTestExportController
NonThrowTryCatch();
}
[Ignore]
[TestMethod]
public void GetExportData()
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Assert.IsTrue(metrologyRepository is not null);
Result<DataTable>? result = exportRepository?.GetExportData(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
[Ignore]
[TestMethod]
public async Task GetExportDataApi()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/1/export?datebegin=&dateend=");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExportData)}.json"), json);
Result<DataTable>? result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<DataTable>>(json);
Assert.IsNotNull(result?.Results);
Assert.IsNotNull(result.Results.Rows.Count > 0);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
[Ignore]
[TestMethod]
public void GetCSVExport()
{
_Logger?.LogInformation("Starting Web Application");
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
IMetrologyRepository? metrologyRepository = serviceProvider?.GetRequiredService<IMetrologyRepository>();
IExportRepository? exportRepository = serviceProvider?.GetRequiredService<IExportRepository>();
Assert.IsTrue(metrologyRepository is not null);
string? result = exportRepository?.GetCSVExport(metrologyRepository, toolTypeId: 1, datebegin: null, dateend: null);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
// [Ignore]
[TestMethod]
public async Task GetCSVExportDat()
{
HttpClient? httpClient = _WebApplicationFactory?.CreateClient();
_Logger?.LogInformation("Starting Web Application");
Assert.IsTrue(httpClient is not null);
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/1/csv?datebegin=&dateend=");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetCSVExport)}.csv"), result);
Assert.IsNotNull(result);
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
}
}