37 lines
1.6 KiB
C#
37 lines
1.6 KiB
C#
using Shouldly;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
|
|
|
/// <summary>
|
|
/// Tests for <see cref="OpcUaClientDriverFactoryExtensions"/> — the factory that lets the
|
|
/// Server-side <c>DriverFactoryBootstrap</c> materialise a real <see cref="OpcUaClientDriver"/>
|
|
/// from a <c>DriverInstance</c> row instead of falling back to a stub.
|
|
/// </summary>
|
|
public class OpcUaClientDriverFactoryTests
|
|
{
|
|
private const string SampleConfig =
|
|
"""{"EndpointUrl":"opc.tcp://host:4840","SecurityMode":"None","AutoAcceptCertificates":true}""";
|
|
|
|
/// <summary>Verifies the factory builds a driver carrying the right type + instance identity.</summary>
|
|
[Fact]
|
|
public void CreateInstance_builds_an_OpcUaClient_driver_with_the_right_identity()
|
|
{
|
|
var driver = OpcUaClientDriverFactoryExtensions.CreateInstance("drv-1", SampleConfig, NullLoggerFactory.Instance);
|
|
driver.DriverType.ShouldBe("OpcUaClient");
|
|
driver.DriverInstanceId.ShouldBe("drv-1");
|
|
}
|
|
|
|
/// <summary>Verifies the public driver-type-name constant matches the driver's DriverType.</summary>
|
|
[Fact]
|
|
public void DriverTypeName_is_OpcUaClient()
|
|
=> OpcUaClientDriverFactoryExtensions.DriverTypeName.ShouldBe("OpcUaClient");
|
|
|
|
/// <summary>Verifies a JSON literal that deserialises to null is rejected with a clear error.</summary>
|
|
[Fact]
|
|
public void CreateInstance_throws_on_null_json_deserialisation()
|
|
=> Should.Throw<System.InvalidOperationException>(
|
|
() => OpcUaClientDriverFactoryExtensions.CreateInstance("drv-1", "null", NullLoggerFactory.Instance));
|
|
}
|