test(infra): add integration smoke test for RealLmxProxyClient against LmxFakeProxy
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../LmxFakeProxy.csproj" />
|
||||
<ProjectReference Include="../../../../src/ScadaLink.DataConnectionLayer/ScadaLink.DataConnectionLayer.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user