test(infra): add integration smoke test for RealLmxProxyClient against LmxFakeProxy

This commit is contained in:
Joseph Doherty
2026-03-19 11:29:00 -04:00
parent 2cb592ad00
commit 8f2700f11e
2 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
using ScadaLink.DataConnectionLayer.Adapters;
namespace LmxFakeProxy.Tests;
/// <summary>
/// End-to-end smoke test connecting RealLmxProxyClient to LmxFakeProxy.
/// Requires both OPC UA test server and LmxFakeProxy to be running.
/// Run manually: dotnet test --filter "Category=Integration"
/// </summary>
[Trait("Category", "Integration")]
public class IntegrationSmokeTest
{
private const string Host = "localhost";
private const int Port = 50051;
[Fact]
public async Task ConnectReadWriteSubscribe_EndToEnd()
{
var factory = new RealLmxProxyClientFactory();
var client = factory.Create(Host, Port, null);
try
{
// Connect
await client.ConnectAsync();
Assert.True(client.IsConnected);
// Read initial value
var vtq = await client.ReadAsync("Motor.Speed");
Assert.Equal(LmxQuality.Good, vtq.Quality);
// Write a value
await client.WriteAsync("Motor.Speed", 42.5);
// Read back
var vtq2 = await client.ReadAsync("Motor.Speed");
Assert.Equal(42.5, (double)vtq2.Value!);
// ReadBatch
var batch = await client.ReadBatchAsync(new[] { "Motor.Speed", "Pump.FlowRate" });
Assert.Equal(2, batch.Count);
// Subscribe briefly
LmxVtq? lastUpdate = null;
var sub = await client.SubscribeAsync(
new[] { "Motor.Speed" },
(tag, v) => lastUpdate = v);
// Write to trigger subscription update
await client.WriteAsync("Motor.Speed", 99.0);
await Task.Delay(2000);
await sub.DisposeAsync();
Assert.NotNull(lastUpdate);
// Disconnect
await client.DisconnectAsync();
}
finally
{
await client.DisposeAsync();
}
}
}

View File

@@ -17,5 +17,6 @@
<ItemGroup>
<ProjectReference Include="../../LmxFakeProxy.csproj" />
<ProjectReference Include="../../../../src/ScadaLink.DataConnectionLayer/ScadaLink.DataConnectionLayer.csproj" />
</ItemGroup>
</Project>