From 8c6a2d92dba106ab531e706f1454854c3da184fe Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Wed, 8 Feb 2023 09:42:52 -0700 Subject: [PATCH] Need DB II --- Server/Repositories/PinRepository.cs | 14 +++++++------- Shared/DataModels/HeaderCommond.cs | 4 ++-- Shared/Models/Stateless/IPinRepository.cs | 2 +- Tests/UnitTestPinController.cs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Server/Repositories/PinRepository.cs b/Server/Repositories/PinRepository.cs index a1f2e58..2d31fbd 100644 --- a/Server/Repositories/PinRepository.cs +++ b/Server/Repositories/PinRepository.cs @@ -16,21 +16,21 @@ public class PinRepository : IPinRepository _Log = Serilog.Log.ForContext(); } - Result IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde) + Result IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde) { - Result? r; + Result? r; HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize(cde); long cdeId = cdeHeader is null ? (long)IPinRepository.ToolId.CDE : cdeHeader.ToolTypeID; HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize(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(), TotalRows = 0 }; + if (cdeId != id && bioRadId != id) + r = new() { Results = Array.Empty(), TotalRows = 0 }; else { if (!string.IsNullOrEmpty(_MockRoot)) { string json = File.ReadAllText(Path.Combine(string.Concat(AppContext.BaseDirectory, _MockRoot), "GetPinnedTableApi.json")); - r = JsonSerializer.Deserialize>(json); + r = JsonSerializer.Deserialize>(json); if (r is null) throw new NullReferenceException(nameof(r)); } @@ -39,8 +39,8 @@ public class PinRepository : IPinRepository const int rows = 11; List values; const int points = 9; - HeaderCommond headerCommond; - List results = new(); + Pinned headerCommond; + List results = new(); if (bioRadHeader is not null) { const int columns = 10; diff --git a/Shared/DataModels/HeaderCommond.cs b/Shared/DataModels/HeaderCommond.cs index a0f9e5d..0211e43 100644 --- a/Shared/DataModels/HeaderCommond.cs +++ b/Shared/DataModels/HeaderCommond.cs @@ -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 values) + public Pinned(HeaderCommon headerCommon, List values) { ID = headerCommon.ID; InsertDate = headerCommon.InsertDate; diff --git a/Shared/Models/Stateless/IPinRepository.cs b/Shared/Models/Stateless/IPinRepository.cs index 6e9257d..61a06ff 100644 --- a/Shared/Models/Stateless/IPinRepository.cs +++ b/Shared/Models/Stateless/IPinRepository.cs @@ -15,6 +15,6 @@ public interface IPinRepository SP1 = 6, } - Result GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde); + Result GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde); } \ No newline at end of file diff --git a/Tests/UnitTestPinController.cs b/Tests/UnitTestPinController.cs index 81f8c0c..35c8f95 100644 --- a/Tests/UnitTestPinController.cs +++ b/Tests/UnitTestPinController.cs @@ -45,7 +45,7 @@ public class UnitTestPinController IPinRepository pinRepository = serviceProvider.GetRequiredService(); 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 result = pinRepository.GetPinnedTable(metrologyRepository, id: 1, bioRad, cde); + Result 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? result = System.Text.Json.JsonSerializer.Deserialize>(json); + Result? result = System.Text.Json.JsonSerializer.Deserialize>(json); Assert.IsNotNull(result?.Results); Assert.IsTrue(result.Results.Any()); _Logger.Information($"{_TestContext?.TestName} completed");