Testing I
This commit is contained in:
parent
65a3c6e7f6
commit
7828493f27
@ -19,7 +19,11 @@ public class PinRepository : IPinRepository
|
|||||||
Result<HeaderCommond[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde)
|
Result<HeaderCommond[]> IPinRepository.GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde)
|
||||||
{
|
{
|
||||||
Result<HeaderCommond[]>? r;
|
Result<HeaderCommond[]>? r;
|
||||||
if (!id.Equals(IPinRepository.ToolId.BioRad) && !id.Equals(IPinRepository.ToolId.CDE))
|
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 };
|
r = new() { Results = Array.Empty<HeaderCommond>(), TotalRows = 0 };
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -32,20 +36,52 @@ public class PinRepository : IPinRepository
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const int rows = 11;
|
||||||
|
List<string> values;
|
||||||
|
const int points = 9;
|
||||||
|
HeaderCommond headerCommond;
|
||||||
List<HeaderCommond> results = new();
|
List<HeaderCommond> results = new();
|
||||||
HeaderCommon? cdeHeader = cde is null ? null : JsonSerializer.Deserialize<HeaderCommon>(cde);
|
|
||||||
HeaderCommon? bioRadHeader = bioRad is null ? null : JsonSerializer.Deserialize<HeaderCommon>(bioRad);
|
|
||||||
if (bioRadHeader is not null)
|
if (bioRadHeader is not null)
|
||||||
{
|
{
|
||||||
System.Data.DataTable dataTable = metrologyRepository.GetData((int)IPinRepository.ToolId.BioRad, bioRadHeader.ID);
|
const int columns = 10;
|
||||||
if (dataTable.Rows.Count == 11)
|
System.Data.DataTable dataTable = metrologyRepository.GetData((int)bioRadHeader.ToolTypeID, bioRadHeader.ID);
|
||||||
;
|
if (dataTable.Rows.Count == rows && dataTable.Columns.Count == columns)
|
||||||
|
{
|
||||||
|
values = new();
|
||||||
|
const int rs = 5;
|
||||||
|
for (int i = 0; i < dataTable.Rows.Count - 1; i++)
|
||||||
|
{
|
||||||
|
if (dataTable.Rows[i]?.ItemArray[rs] is null)
|
||||||
|
break;
|
||||||
|
values.Add(string.Concat(dataTable.Rows[i].ItemArray[rs]));
|
||||||
|
}
|
||||||
|
if (values.Count > points)
|
||||||
|
{
|
||||||
|
headerCommond = new(bioRadHeader, values);
|
||||||
|
results.Add(headerCommond);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cdeHeader is not null)
|
if (cdeHeader is not null)
|
||||||
{
|
{
|
||||||
System.Data.DataTable dataTable = metrologyRepository.GetData((int)IPinRepository.ToolId.CDE, cdeHeader.ID);
|
const int columns = 7;
|
||||||
if (dataTable.Rows.Count == 11)
|
System.Data.DataTable dataTable = metrologyRepository.GetData((int)cdeHeader.ToolTypeID, cdeHeader.ID);
|
||||||
;
|
if (dataTable.Rows.Count == rows && dataTable.Columns.Count == columns)
|
||||||
|
{
|
||||||
|
values = new();
|
||||||
|
const int rs = 5;
|
||||||
|
for (int i = 0; i < dataTable.Rows.Count - 1; i++)
|
||||||
|
{
|
||||||
|
if (dataTable.Rows[i]?.ItemArray[rs] is null)
|
||||||
|
break;
|
||||||
|
values.Add(string.Concat(dataTable.Rows[i].ItemArray[rs]));
|
||||||
|
}
|
||||||
|
if (values.Count > points)
|
||||||
|
{
|
||||||
|
headerCommond = new(cdeHeader, values);
|
||||||
|
results.Add(headerCommond);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r = new()
|
r = new()
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
"ConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;",
|
"xConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Integrated Security=True;Initial Catalog=Metrology;",
|
||||||
|
"ConnectionString": "Data Source=messv01ec.ec.local\\PROD1,53959;Integrated Security=True;Initial Catalog=Metrology;",
|
||||||
"IsDevelopment": true,
|
"IsDevelopment": true,
|
||||||
"MockRoot": "/Data/Tests",
|
"xMockRoot": "/Data/Tests",
|
||||||
|
"MockRoot": "",
|
||||||
"MonAResource": "OI_Metrology_Viewer_IFX",
|
"MonAResource": "OI_Metrology_Viewer_IFX",
|
||||||
"Oi2SqlConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;",
|
"Oi2SqlConnectionString": "Data Source=MESSAD1001\\TEST1,59583;Initial Catalog=LSL2SQL;Persist Security Info=True;User ID=srpadmin;Password=0okm9ijn;",
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
|
@ -2,16 +2,39 @@
|
|||||||
|
|
||||||
public class HeaderCommond : HeaderCommon
|
public class HeaderCommond : HeaderCommon
|
||||||
{
|
{
|
||||||
public string? PointA { get; set; }
|
|
||||||
public string? PointB { get; set; }
|
public string PointA { get; set; }
|
||||||
public string? PointC { get; set; }
|
public string PointB { get; set; }
|
||||||
public string? PointD { get; set; }
|
public string PointC { get; set; }
|
||||||
public string? PointE { get; set; }
|
public string PointD { get; set; }
|
||||||
public string? PointF { get; set; }
|
public string PointE { get; set; }
|
||||||
public string? PointG { get; set; }
|
public string PointF { get; set; }
|
||||||
public string? PointH { get; set; }
|
public string PointG { get; set; }
|
||||||
public string? PointI { get; set; }
|
public string PointH { get; set; }
|
||||||
public string? PointJ { get; set; }
|
public string PointI { get; set; }
|
||||||
public string? PointK { get; set; }
|
|
||||||
public string? PointL { get; set; }
|
public HeaderCommond(HeaderCommon headerCommon, List<string> values)
|
||||||
|
{
|
||||||
|
ID = headerCommon.ID;
|
||||||
|
InsertDate = headerCommon.InsertDate;
|
||||||
|
AttachmentID = headerCommon.AttachmentID;
|
||||||
|
Title = headerCommon.Title;
|
||||||
|
Recipe = headerCommon.Recipe;
|
||||||
|
Date = headerCommon.Date;
|
||||||
|
ToolTypeID = headerCommon.ToolTypeID;
|
||||||
|
ToolTypeName = headerCommon.ToolTypeName;
|
||||||
|
Reactor = headerCommon.Reactor;
|
||||||
|
RDS = headerCommon.RDS;
|
||||||
|
PSN = headerCommon.PSN;
|
||||||
|
PointA = values[0];
|
||||||
|
PointB = values[1];
|
||||||
|
PointC = values[2];
|
||||||
|
PointD = values[3];
|
||||||
|
PointE = values[4];
|
||||||
|
PointF = values[5];
|
||||||
|
PointG = values[6];
|
||||||
|
PointH = values[7];
|
||||||
|
PointI = values[8];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -7,12 +7,12 @@ public interface IPinRepository
|
|||||||
|
|
||||||
enum ToolId
|
enum ToolId
|
||||||
{
|
{
|
||||||
BioRad = 0,
|
BioRad = 1,
|
||||||
CDE = 1,
|
CDE = 2,
|
||||||
Tencor = 2,
|
Tencor = 3,
|
||||||
HgCV = 3,
|
HgCV = 4,
|
||||||
Stratus = 4,
|
Stratus = 5,
|
||||||
SP1 = 5,
|
SP1 = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<HeaderCommond[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde);
|
Result<HeaderCommond[]> GetPinnedTable(IMetrologyRepository metrologyRepository, int id, string? bioRad, string? cde);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" 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.DependencyInjection" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
||||||
|
@ -43,9 +43,9 @@ public class UnitTestPinController
|
|||||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||||
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
|
IMetrologyRepository metrologyRepository = serviceProvider.GetRequiredService<IMetrologyRepository>();
|
||||||
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>();
|
IPinRepository pinRepository = serviceProvider.GetRequiredService<IPinRepository>();
|
||||||
string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 0, ToolTypeID = 0 });
|
string? cde = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 196984, ToolTypeID = 2 });
|
||||||
string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 0, ToolTypeID = 0 });
|
string? bioRad = System.Text.Json.JsonSerializer.Serialize(new HeaderCommon { ID = 321568, ToolTypeID = 1 });
|
||||||
Result<HeaderCommond[]> result = pinRepository.GetPinnedTable(metrologyRepository, id: 0, bioRad, cde);
|
Result<HeaderCommond[]> 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");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user