2b8b5fbdb2
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
35 lines
1.5 KiB
C#
35 lines
1.5 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for the IReadable/IWritable surface that don't need a live remote OPC UA
|
|
/// server (the uninitialised-guard contract). The wire-level read/write round-trips live in
|
|
/// <c>OpcUaServer.IntegrationTests/OpcUaClientDriverWireTests</c>, against the in-process server.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class OpcUaClientReadWriteTests
|
|
{
|
|
/// <summary>Verifies that ReadAsync throws InvalidOperationException when not initialized.</summary>
|
|
[Fact]
|
|
public async Task ReadAsync_without_initialize_throws_InvalidOperationException()
|
|
{
|
|
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-uninit");
|
|
await Should.ThrowAsync<InvalidOperationException>(async () =>
|
|
await drv.ReadAsync(["ns=2;s=Demo"], TestContext.Current.CancellationToken));
|
|
}
|
|
|
|
/// <summary>Verifies that WriteAsync throws InvalidOperationException when not initialized.</summary>
|
|
[Fact]
|
|
public async Task WriteAsync_without_initialize_throws_InvalidOperationException()
|
|
{
|
|
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-uninit");
|
|
await Should.ThrowAsync<InvalidOperationException>(async () =>
|
|
await drv.WriteAsync(
|
|
[new WriteRequest("ns=2;s=Demo", 42)],
|
|
TestContext.Current.CancellationToken));
|
|
}
|
|
}
|