test(adminui): close Phase 6 review test-gaps + Enterprise-delete warning
This commit is contained in:
@@ -123,4 +123,24 @@ public sealed class TagHistorizeConfigTests
|
||||
json.ShouldStartWith("{");
|
||||
json.ShouldEndWith("}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Full seam: the history helper and a driver-typed editor compose over the same canonical TagConfig
|
||||
/// blob without clobbering each other. Setting the history keys, round-tripping through the
|
||||
/// OpcUaClient typed editor (FromJson → ToJson), then reading the history keys back recovers them
|
||||
/// intact — and the editor's own FullName field survives the history merge.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void History_keys_survive_a_typed_editor_round_trip()
|
||||
{
|
||||
var withHistory = TagHistorizeConfig.Set(
|
||||
"""{"FullName":"ns=2;s=X"}""", isHistorized: true, historianTagname: "TN");
|
||||
|
||||
var afterEditor = OpcUaClientTagConfigModel.FromJson(withHistory).ToJson();
|
||||
|
||||
var h = TagHistorizeConfig.Read(afterEditor);
|
||||
h.IsHistorized.ShouldBeTrue();
|
||||
h.HistorianTagname.ShouldBe("TN");
|
||||
OpcUaClientTagConfigModel.FromJson(afterEditor).FullName.ShouldBe("ns=2;s=X");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,63 @@ public sealed class UnsTreeServiceDeleteClusterTests
|
||||
verify.ServerClusters.Any(c => c.ClusterId == "CL-DRV").ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>A cluster with a cluster node refuses deletion with a friendly message and stays put.</summary>
|
||||
[Fact]
|
||||
public async Task DeleteCluster_with_cluster_node_refuses_and_keeps_row()
|
||||
{
|
||||
var (service, dbName) = Fresh();
|
||||
using (var db = UnsTreeTestDb.CreateNamed(dbName))
|
||||
{
|
||||
db.ServerClusters.Add(NewCluster("CL-NODE", "zb"));
|
||||
db.ClusterNodes.Add(new ClusterNode
|
||||
{
|
||||
NodeId = "NODE-CL",
|
||||
ClusterId = "CL-NODE",
|
||||
Host = "host-a",
|
||||
ApplicationUri = "urn:zb:cl-node:a",
|
||||
CreatedBy = "test",
|
||||
});
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
||||
var result = await service.DeleteClusterAsync("CL-NODE");
|
||||
|
||||
result.Ok.ShouldBeFalse();
|
||||
result.Error.ShouldNotBeNull();
|
||||
result.Error.ShouldContain("CL-NODE");
|
||||
|
||||
using var verify = UnsTreeTestDb.CreateNamed(dbName);
|
||||
verify.ServerClusters.Any(c => c.ClusterId == "CL-NODE").ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>A cluster with a namespace refuses deletion with a friendly message and stays put.</summary>
|
||||
[Fact]
|
||||
public async Task DeleteCluster_with_namespace_refuses_and_keeps_row()
|
||||
{
|
||||
var (service, dbName) = Fresh();
|
||||
using (var db = UnsTreeTestDb.CreateNamed(dbName))
|
||||
{
|
||||
db.ServerClusters.Add(NewCluster("CL-NS", "zb"));
|
||||
db.Namespaces.Add(new Namespace
|
||||
{
|
||||
NamespaceId = "NS-CL",
|
||||
ClusterId = "CL-NS",
|
||||
Kind = NamespaceKind.Equipment,
|
||||
NamespaceUri = "urn:zb:cl-ns:equipment",
|
||||
});
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
||||
var result = await service.DeleteClusterAsync("CL-NS");
|
||||
|
||||
result.Ok.ShouldBeFalse();
|
||||
result.Error.ShouldNotBeNull();
|
||||
result.Error.ShouldContain("CL-NS");
|
||||
|
||||
using var verify = UnsTreeTestDb.CreateNamed(dbName);
|
||||
verify.ServerClusters.Any(c => c.ClusterId == "CL-NS").ShouldBeTrue();
|
||||
}
|
||||
|
||||
// ----- DeleteEnterprise -----
|
||||
|
||||
/// <summary>Deleting an enterprise whose every cluster is child-free removes them all.</summary>
|
||||
|
||||
Reference in New Issue
Block a user