30 lines
1.4 KiB
C#
30 lines
1.4 KiB
C#
using System.Text.Json;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
|
|
|
/// <summary>#954: the factory parses the AlarmRefreshRequiredMinInterval shape the AdminUI form writes.</summary>
|
|
public sealed class OpcUaClientAlarmRefreshIntervalConfigTests
|
|
{
|
|
[Theory]
|
|
[InlineData("""{"endpointUrl":"opc.tcp://x:1","alarmRefreshRequiredMinInterval":"00:00:30"}""", 30.0)]
|
|
[InlineData("""{"endpointUrl":"opc.tcp://x:1","alarmRefreshRequiredMinInterval":"00:00:00"}""", 0.0)]
|
|
[InlineData("""{"endpointUrl":"opc.tcp://x:1","alarmRefreshRequiredMinInterval":"00:00:00.5000000"}""", 0.5)]
|
|
[InlineData("""{"endpointUrl":"opc.tcp://x:1"}""", 10.0)]
|
|
public void ParseOptions_ReadsFormShape(string json, double expectedSeconds) =>
|
|
OpcUaClientDriverFactoryExtensions.ParseOptions("d", json).AlarmRefreshRequiredMinInterval
|
|
.ShouldBe(TimeSpan.FromSeconds(expectedSeconds));
|
|
|
|
[Fact]
|
|
public void ParseOptions_ReadsSerializedOptions()
|
|
{
|
|
var json = JsonSerializer.Serialize(
|
|
new OpcUaClientDriverOptions { AlarmRefreshRequiredMinInterval = TimeSpan.FromSeconds(7) },
|
|
new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
|
OpcUaClientDriverFactoryExtensions.ParseOptions("d", json).AlarmRefreshRequiredMinInterval
|
|
.ShouldBe(TimeSpan.FromSeconds(7));
|
|
}
|
|
}
|