Merge re/r1.4-gethi-finding: R1.1 ExecuteSqlCommand + R1.4 GetHistorianInfo (bounded)
# Conflicts: # docs/plans/hcal-roadmap.md # src/AVEVA.Historian.Client/HistorianClient.cs # src/AVEVA.Historian.Client/Protocol/Historian2020ProtocolDialect.cs # tests/AVEVA.Historian.Client.Tests/HistorianClientIntegrationTests.cs # tools/AVEVA.Historian.NativeTraceHarness/Program.cs
This commit is contained in:
@@ -331,6 +331,65 @@ public sealed class HistorianClientIntegrationTests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteSqlCommandAsync_AgainstLocalHistorian_ReturnsRecordSet()
|
||||
{
|
||||
string? host = Environment.GetEnvironmentVariable("HISTORIAN_HOST");
|
||||
if (string.IsNullOrWhiteSpace(host) || !string.Equals(host, "localhost", StringComparison.OrdinalIgnoreCase) || !OperatingSystem.IsWindows())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HistorianClient client = new(new HistorianClientOptions
|
||||
{
|
||||
Host = host,
|
||||
IntegratedSecurity = true,
|
||||
Transport = HistorianTransport.LocalPipe
|
||||
});
|
||||
|
||||
// ExeC/GetR ride the storage-session GUID as an uppercase string handle. A constant SELECT
|
||||
// returns a single int column; the DataTable is decoded from the NRBF stream (no BinaryFormatter).
|
||||
AVEVA.Historian.Client.Models.HistorianSqlResult result =
|
||||
await client.ExecuteSqlCommandAsync("SELECT 1 AS ProbeValue", cancellationToken: CancellationToken.None);
|
||||
|
||||
AVEVA.Historian.Client.Models.HistorianSqlColumn column = Assert.Single(result.Columns);
|
||||
Assert.Equal("ProbeValue", column.Name);
|
||||
IReadOnlyList<object?> row = Assert.Single(result.Rows);
|
||||
Assert.Equal(1, Assert.Single(row));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteSqlCommandAsync_AgainstLocalHistorian_MultiColumnMultiRow()
|
||||
{
|
||||
string? host = Environment.GetEnvironmentVariable("HISTORIAN_HOST");
|
||||
if (string.IsNullOrWhiteSpace(host) || !string.Equals(host, "localhost", StringComparison.OrdinalIgnoreCase) || !OperatingSystem.IsWindows())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HistorianClient client = new(new HistorianClientOptions
|
||||
{
|
||||
Host = host,
|
||||
IntegratedSecurity = true,
|
||||
Transport = HistorianTransport.LocalPipe
|
||||
});
|
||||
|
||||
// Fully synthetic query (no server data): two columns (int + string), two rows, one NULL —
|
||||
// exercises the schema/diffgram parser beyond the single-cell case.
|
||||
AVEVA.Historian.Client.Models.HistorianSqlResult result = await client.ExecuteSqlCommandAsync(
|
||||
"SELECT 10 AS Num, 'alpha' AS Word UNION ALL SELECT 20, NULL",
|
||||
cancellationToken: CancellationToken.None);
|
||||
|
||||
Assert.Equal(2, result.Columns.Count);
|
||||
Assert.Equal("Num", result.Columns[0].Name);
|
||||
Assert.Equal("Word", result.Columns[1].Name);
|
||||
Assert.Equal(2, result.Rows.Count);
|
||||
Assert.Equal(10, result.Rows[0][0]);
|
||||
Assert.Equal("alpha", result.Rows[0][1]);
|
||||
Assert.Equal(20, result.Rows[1][0]);
|
||||
Assert.Null(result.Rows[1][1]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetConnectionStatusAsync_AgainstLocalHistorian_ReportsConnectedToServer()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user