using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.Admin.Components.Pages.Modbus; using ZB.MOM.WW.OtOpcUa.Driver.Modbus; namespace ZB.MOM.WW.OtOpcUa.Admin.Tests; /// /// #145 Admin UI: smoke coverage for the ModbusOptionsEditor view model. The Blazor /// component itself is exercised in browser-runtime tests; this fixture pins the default /// values the form initialises to so a regression that flips an unedited row to a /// non-default value gets caught. /// [Trait("Category", "Unit")] public sealed class ModbusOptionsViewModelTests { [Fact] public void Defaults_Match_DriverOption_Defaults() { var vm = new ModbusOptionsEditor.ModbusOptionsViewModel(); var driverDefault = new ModbusDriverOptions(); vm.Host.ShouldBe(driverDefault.Host); vm.Port.ShouldBe(driverDefault.Port); vm.UnitId.ShouldBe(driverDefault.UnitId); vm.Family.ShouldBe(driverDefault.Family); vm.MelsecSubFamily.ShouldBe(driverDefault.MelsecSubFamily); vm.KeepAliveEnabled.ShouldBe(driverDefault.KeepAlive.Enabled); vm.KeepAliveTimeSec.ShouldBe((int)driverDefault.KeepAlive.Time.TotalSeconds); vm.KeepAliveIntervalSec.ShouldBe((int)driverDefault.KeepAlive.Interval.TotalSeconds); vm.KeepAliveRetryCount.ShouldBe(driverDefault.KeepAlive.RetryCount); vm.ReconnectInitialDelayMs.ShouldBe((int)driverDefault.Reconnect.InitialDelay.TotalMilliseconds); vm.ReconnectMaxDelayMs.ShouldBe((int)driverDefault.Reconnect.MaxDelay.TotalMilliseconds); vm.ReconnectBackoffMultiplier.ShouldBe(driverDefault.Reconnect.BackoffMultiplier); vm.MaxRegistersPerRead.ShouldBe(driverDefault.MaxRegistersPerRead); vm.MaxRegistersPerWrite.ShouldBe(driverDefault.MaxRegistersPerWrite); vm.MaxCoilsPerRead.ShouldBe(driverDefault.MaxCoilsPerRead); vm.MaxReadGap.ShouldBe(driverDefault.MaxReadGap); vm.UseFC15ForSingleCoilWrites.ShouldBe(driverDefault.UseFC15ForSingleCoilWrites); vm.UseFC16ForSingleRegisterWrites.ShouldBe(driverDefault.UseFC16ForSingleRegisterWrites); vm.WriteOnChangeOnly.ShouldBe(driverDefault.WriteOnChangeOnly); } }