Need DB II
This commit is contained in:
parent
7828493f27
commit
8c6a2d92db
@ -16,21 +16,21 @@ public class PinRepository : IPinRepository
|
||||
_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);
|
||||
long cdeId = cdeHeader is null ? (long)IPinRepository.ToolId.CDE : cdeHeader.ToolTypeID;
|
||||
HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad);
|
||||
long bioRadId = bioRadHeader is null ? (long)IPinRepository.ToolId.BioRad : bioRadHeader.ToolTypeID;
|
||||
if (cdeHeader is not null && cdeHeader.ToolTypeID != id && bioRadHeader?.ToolTypeID != id)
|
||||
r = new() { Results = Array.Empty<HeaderCommond>(), TotalRows = 0 };
|
||||
if (cdeId != id && bioRadId != id)
|
||||
r = new() { Results = Array.Empty<Pinned>(), TotalRows = 0 };
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_MockRoot))
|
||||
{
|
||||
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)
|
||||
throw new NullReferenceException(nameof(r));
|
||||
}
|
||||
@ -39,8 +39,8 @@ public class PinRepository : IPinRepository
|
||||
const int rows = 11;
|
||||
List<string> values;
|
||||
const int points = 9;
|
||||
HeaderCommond headerCommond;
|
||||
List<HeaderCommond> results = new();
|
||||
Pinned headerCommond;
|
||||
List<Pinned> results = new();
|
||||
if (bioRadHeader is not null)
|
||||
{
|
||||
const int columns = 10;
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace OI.Metrology.Shared.DataModels;
|
||||
|
||||
public class HeaderCommond : HeaderCommon
|
||||
public class Pinned : HeaderCommon
|
||||
{
|
||||
|
||||
public string PointA { get; set; }
|
||||
@ -13,7 +13,7 @@ public class HeaderCommond : HeaderCommon
|
||||
public string PointH { get; set; }
|
||||
public string PointI { get; set; }
|
||||
|
||||
public HeaderCommond(HeaderCommon headerCommon, List<string> values)
|
||||
public Pinned(HeaderCommon headerCommon, List<string> values)
|
||||
{
|
||||
ID = headerCommon.ID;
|
||||
InsertDate = headerCommon.InsertDate;
|
||||
|
@ -15,6 +15,6 @@ public interface IPinRepository
|
||||
SP1 = 6,
|
||||
}
|
||||
|
||||
Result<HeaderCommond[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde);
|
||||
Result<Pinned[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde);
|
||||
|
||||
}
|
@ -45,7 +45,7 @@ public class UnitTestPinController
|
||||
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>();
|
||||
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 });
|
||||
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.IsTrue(result.Results.Any());
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
@ -58,7 +58,7 @@ public class UnitTestPinController
|
||||
_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<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.IsTrue(result.Results.Any());
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
|
Loading…
x
Reference in New Issue
Block a user