test(inbound): add namespace + Query() coverage for InboundDatabaseHelper
This commit is contained in:
@@ -5,6 +5,8 @@ using ZB.MOM.WW.ScadaBridge.Commons.Types;
|
|||||||
using ZB.MOM.WW.ScadaBridge.InboundAPI;
|
using ZB.MOM.WW.ScadaBridge.InboundAPI;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
namespace ZB.MOM.WW.ScadaBridge.InboundAPI.Tests;
|
||||||
|
|
||||||
public class InboundDatabaseHelperTests
|
public class InboundDatabaseHelperTests
|
||||||
{
|
{
|
||||||
private sealed class SqliteGateway : IDatabaseGateway
|
private sealed class SqliteGateway : IDatabaseGateway
|
||||||
@@ -44,4 +46,23 @@ public class InboundDatabaseHelperTests
|
|||||||
var code = helper.QuerySingle<string>("BTDB", "SELECT Code FROM Machine WHERE SAPID=@s", new { s = "999999" });
|
var code = helper.QuerySingle<string>("BTDB", "SELECT Code FROM Machine WHERE SAPID=@s", new { s = "999999" });
|
||||||
Assert.Null(code);
|
Assert.Null(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Query_returns_row_with_case_insensitive_keys()
|
||||||
|
{
|
||||||
|
var helper = new InboundDatabaseHelper(SeededGateway(), CancellationToken.None);
|
||||||
|
var rows = helper.Query("BTDB", "SELECT Code, SAPID FROM Machine WHERE SAPID=@s", new { s = "131453" });
|
||||||
|
Assert.Single(rows);
|
||||||
|
var row = rows[0];
|
||||||
|
Assert.Equal("Z28061A", row["code"]);
|
||||||
|
Assert.Equal("Z28061A", row["CODE"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Query_returns_empty_list_when_no_rows_match()
|
||||||
|
{
|
||||||
|
var helper = new InboundDatabaseHelper(SeededGateway(), CancellationToken.None);
|
||||||
|
var rows = helper.Query("BTDB", "SELECT Code, SAPID FROM Machine WHERE SAPID=@s", new { s = "999999" });
|
||||||
|
Assert.Empty(rows);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user