feat(adminui): #954 OpcUaClient driver form field for AlarmRefreshRequiredMinInterval (+ round-trip and factory-parse tests)
This commit is contained in:
+30
@@ -142,6 +142,36 @@ public sealed class OpcUaClientDriverPageFormSerializationTests
|
||||
result.ProbeTimeoutSeconds.ShouldBe(25);
|
||||
}
|
||||
|
||||
/// <summary>#954: AlarmRefreshRequiredMinInterval must survive the form (default 10 s; 0 = off; sub-second kept).</summary>
|
||||
[Theory]
|
||||
[InlineData(10.0)]
|
||||
[InlineData(0.0)]
|
||||
[InlineData(45.0)]
|
||||
[InlineData(0.5)]
|
||||
public void FormModel_RoundTrip_PreservesAlarmRefreshRequiredMinInterval(double seconds)
|
||||
{
|
||||
var original = new OpcUaClientDriverOptions { AlarmRefreshRequiredMinInterval = TimeSpan.FromSeconds(seconds) };
|
||||
|
||||
var form = OpcUaClientDriverForm.OpcUaClientFormModel.FromRecord(original);
|
||||
form.AlarmRefreshRequiredMinIntervalSeconds.ShouldBe(seconds);
|
||||
var back = form.ToRecord([]);
|
||||
|
||||
back.AlarmRefreshRequiredMinInterval.ShouldBe(TimeSpan.FromSeconds(seconds));
|
||||
// Through the wire shape the form emits (camelCase options JSON, TimeSpan as "hh:mm:ss").
|
||||
var json = JsonSerializer.Serialize(back, _opts);
|
||||
JsonSerializer.Deserialize<OpcUaClientDriverOptions>(json, _opts)!
|
||||
.AlarmRefreshRequiredMinInterval.ShouldBe(TimeSpan.FromSeconds(seconds));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormModel_DefaultAlarmRefreshRequiredMinInterval_MatchesDriverDefault()
|
||||
{
|
||||
new OpcUaClientDriverForm.OpcUaClientFormModel().ToRecord([]).AlarmRefreshRequiredMinInterval
|
||||
.ShouldBe(new OpcUaClientDriverOptions().AlarmRefreshRequiredMinInterval);
|
||||
new OpcUaClientDriverForm.OpcUaClientFormModel { AlarmRefreshRequiredMinIntervalSeconds = -5 }.ToRecord([])
|
||||
.AlarmRefreshRequiredMinInterval.ShouldBe(TimeSpan.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #273/#275/#277/#278: the typed form rewrites the whole record on save, so a key it does not model
|
||||
/// is silently dropped (#576). Every new option must survive FromRecord -> ToRecord.
|
||||
|
||||
Reference in New Issue
Block a user