test(adminui): migrate AdminUI.Tests to v3 greenfield schema + Batch-1 stubs

Migrate tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests (was 358 build errors) to
the v3 Raw-only Tag schema and the Batch-1 AdminUI stubs. Production untouched.

- Driver-page serialization tests: drop the retired pre-declared Tags editor
  (page *TagRow types + DriverOptions.Tags); multi-device pages keep their
  Devices editor (ToOptions(devices)). Enum-serialization round-trip coverage
  (CpuType/ModbusFamily/MelsecFamily/AbCipPlcFamily/AbLegacyPlcFamily/FocasCncSeries)
  preserved intact.
- UnsTreeTestDb: reseed to v3 (Device->Tag raw slice, no EquipmentId/DriverInstanceId
  on Tag, no Namespace).
- UnsTreeService tag tests: assert Batch-1 stubs (CreateTag/UpdateTag refusal,
  empty tag/tag-driver lists); DeleteTag stays live against a raw Tag.
- Equipment #122 guard retained (validates input driver vs line cluster); drop the
  retired persisted-binding assertions + NamespaceId seeds. Area/Line #122 driver-
  orphan guard retired -> assert cross-cluster move now succeeds.
- DeleteCluster: drop the deleted-Namespace child-check test.
- OpcUaClientTagConfigModel/TagConfigValidator: address key FullName -> nodeId.
- ScriptTagCatalog: project surviving Name/DataType/TagConfig; DriverInstanceId null.
- VirtualTag {{equip}} equipment-tag-derived base is dark -> 3 tests skipped (Batch-3).

Result: build green; 507 passed / 3 skipped / 0 failed.
This commit is contained in:
Joseph Doherty
2026-07-15 21:50:48 -04:00
parent aaba2ebd66
commit 6a616a1ab2
22 changed files with 266 additions and 1029 deletions
@@ -15,12 +15,6 @@ public sealed class ModbusDriverPageFormSerializationTests
WriteIndented = false,
};
private static readonly JsonSerializerOptions TestJsonOpts = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
UnmappedMemberHandling = JsonUnmappedMemberHandling.Skip,
};
[Fact]
public void RoundTrip_PreservesKnownFields()
{
@@ -112,62 +106,9 @@ public sealed class ModbusDriverPageFormSerializationTests
back.ProbeTimeoutSeconds.ShouldBe(10);
}
[Fact]
public void TagRow_round_trips_through_definition()
{
var row = new ModbusDriverPage.ModbusTagRow
{
Name = "Pump1_Speed", Region = ModbusRegion.HoldingRegisters, Address = 40001,
DataType = ModbusDataType.Int16, Writable = true,
};
var def = row.ToDefinition();
var back = ModbusDriverPage.ModbusTagRow.FromDefinition(def);
back.Name.ShouldBe("Pump1_Speed");
back.Address.ShouldBe(40001);
back.DataType.ShouldBe(ModbusDataType.Int16);
back.Writable.ShouldBeTrue();
}
[Fact]
public void Tag_list_survives_options_serialize_round_trip()
{
var tags = new List<ModbusTagDefinition>
{
new("A", ModbusRegion.HoldingRegisters, 1, ModbusDataType.Int16),
new("B", ModbusRegion.Coils, 2, ModbusDataType.Bool),
};
var opts = new ModbusDriverPage.FormModel().ToOptions(tags);
var json = JsonSerializer.Serialize(opts, TestJsonOpts);
var back = JsonSerializer.Deserialize<ModbusDriverOptions>(json, TestJsonOpts)!;
back.Tags.Count.ShouldBe(2);
back.Tags[0].Name.ShouldBe("A");
}
[Fact]
public void ValidateRow_rejects_duplicate_name()
{
var rows = new List<ModbusDriverPage.ModbusTagRow> { new() { Name = "A" } };
ModbusDriverPage.ModbusTagRow.ValidateRow(new() { Name = "A" }, rows, null)
.ShouldNotBeNull();
}
[Fact]
public void ToDefinition_preserves_unedited_fields()
{
var original = new ModbusTagDefinition(
"T", ModbusRegion.HoldingRegisters, 5, ModbusDataType.Int16,
StringByteOrder: ModbusStringByteOrder.LowByteFirst,
ArrayCount: 10, Deadband: 0.5, UnitId: 3, CoalesceProhibited: true);
var row = ModbusDriverPage.ModbusTagRow.FromDefinition(original);
row.Name = "Renamed";
var back = row.ToDefinition();
back.Name.ShouldBe("Renamed");
back.UnitId.ShouldBe((byte)3);
back.ArrayCount.ShouldBe(10);
back.Deadband.ShouldBe(0.5);
back.StringByteOrder.ShouldBe(ModbusStringByteOrder.LowByteFirst);
back.CoalesceProhibited.ShouldBeTrue();
}
// v3 Batch-1 migration: the pre-declared Tags editor (ModbusDriverPage.ModbusTagRow +
// ModbusDriverOptions.Tags) was retired — tags moved to the Raw tree (/raw, Batch 2). The former
// TagRow_* / Tag_list_survives_* / ValidateRow_* / ToDefinition_preserves_* tests were removed.
// The connection/protocol-field + enum-serialization coverage (ModbusFamily, MelsecFamily) is
// retained by RoundTrip_PreservesKnownFields above unchanged.
}