Need DB II

This commit is contained in:
Mike Phares 2023-02-08 09:42:52 -07:00
parent 7828493f27
commit 8c6a2d92db
4 changed files with 12 additions and 12 deletions

View File

@ -16,21 +16,21 @@ public class PinRepository : IPinRepository
_Log = Serilog.Log.ForContext<PinRepository>(); _Log = Serilog.Log.ForContext<PinRepository>();
} }
Result<HeaderCommond[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde) Result<Pinned[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde)
{ {
Result<HeaderCommond[]>? r; Result<Pinned[]>? r;
HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize<HeaderCommon>(cde); HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize<HeaderCommon>(cde);
long cdeId = cdeHeader is null ? (long)IPinRepository.ToolId.CDE : cdeHeader.ToolTypeID; long cdeId = cdeHeader is null ? (long)IPinRepository.ToolId.CDE : cdeHeader.ToolTypeID;
HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad); HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad);
long bioRadId = bioRadHeader is null ? (long)IPinRepository.ToolId.BioRad : bioRadHeader.ToolTypeID; long bioRadId = bioRadHeader is null ? (long)IPinRepository.ToolId.BioRad : bioRadHeader.ToolTypeID;
if (cdeHeader is not null && cdeHeader.ToolTypeID != id && bioRadHeader?.ToolTypeID != id) if (cdeId != id && bioRadId != id)
r = new() { Results = Array.Empty<HeaderCommond>(), TotalRows = 0 }; r = new() { Results = Array.Empty<Pinned>(), TotalRows = 0 };
else else
{ {
if (!string.IsNullOrEmpty(_MockRoot)) if (!string.IsNullOrEmpty(_MockRoot))
{ {
string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetPinnedTableApi.json")); string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetPinnedTableApi.json"));
r = JsonSerializer.Deserialize<Result<HeaderCommond[]>>(json); r = JsonSerializer.Deserialize<Result<Pinned[]>>(json);
if (r is null) if (r is null)
throw new NullReferenceException(nameof(r)); throw new NullReferenceException(nameof(r));
} }
@ -39,8 +39,8 @@ public class PinRepository : IPinRepository
const int rows = 11; const int rows = 11;
List<string> values; List<string> values;
const int points = 9; const int points = 9;
HeaderCommond headerCommond; Pinned headerCommond;
List<HeaderCommond> results = new(); List<Pinned> results = new();
if (bioRadHeader is not null) if (bioRadHeader is not null)
{ {
const int columns = 10; const int columns = 10;

View File

@ -1,6 +1,6 @@
namespace OI.Metrology.Shared.DataModels; namespace OI.Metrology.Shared.DataModels;
public class HeaderCommond : HeaderCommon public class Pinned : HeaderCommon
{ {
public string PointA { get; set; } public string PointA { get; set; }
@ -13,7 +13,7 @@ public class HeaderCommond : HeaderCommon
public string PointH { get; set; } public string PointH { get; set; }
public string PointI { get; set; } public string PointI { get; set; }
public HeaderCommond(HeaderCommon headerCommon, List<string> values) public Pinned(HeaderCommon headerCommon, List<string> values)
{ {
ID = headerCommon.ID; ID = headerCommon.ID;
InsertDate = headerCommon.InsertDate; InsertDate = headerCommon.InsertDate;

View File

@ -15,6 +15,6 @@ public interface IPinRepository
SP1 = 6, SP1 = 6,
} }
Result<HeaderCommond[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde); Result<Pinned[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde);
} }

View File

@ -45,7 +45,7 @@ public class UnitTestPinController
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>(); IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>();
string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 196984, ToolTypeID = 2 }); string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 196984, ToolTypeID = 2 });
string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 321568, ToolTypeID = 1 }); string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 321568, ToolTypeID = 1 });
Result<HeaderCommond[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, bioRad, cde); Result<Pinned[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, bioRad, cde);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result.Results.Any());
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");
@ -58,7 +58,7 @@ public class UnitTestPinController
_Logger.Information("Starting Web Application"); _Logger.Information("Starting Web Application");
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles"); string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/-1/headertitles");
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeaderTitlesApi)}.json"), json); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{nameof(GetHeaderTitlesApi)}.json"), json);
Result<HeaderCommond[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommond[]>>(json); Result<Pinned[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<Pinned[]>>(json);
Assert.IsNotNull(result?.Results); Assert.IsNotNull(result?.Results);
Assert.IsTrue(result.Results.Any()); Assert.IsTrue(result.Results.Any());
_Logger.Information($"{_TestContext?.TestName} completed"); _Logger.Information($"{_TestContext?.TestName} completed");