fix(centralui): grouped bindings review fixes — Apply with the header at none/mixed keeps each member's connection (never unbinds; upsert Save could not persist it), object inference runs over effective references (bare-default members make an overridden group mixed, default-only prefixes infer), bindings to a deleted connection count as unbound, 'n changed · unsaved' diffs against last-saved state; bUnit behaviour tests for fallback banner, grouping and mixed-group Apply+Save
This commit is contained in:
@@ -142,4 +142,60 @@ public class BindingGroupBuilderTests
|
||||
Assert.Null(c.Override);
|
||||
Assert.Equal(2, c.ConnectionId);
|
||||
}
|
||||
|
||||
// ── Review fixes 2026-08-20 ──
|
||||
|
||||
[Fact]
|
||||
public void ApplyObject_NullConnection_KeepsEachMembersCurrentConnection()
|
||||
{
|
||||
// A header reading "— mixed —"/"— none —" (0) must not unbind the group:
|
||||
// Save is an upsert, so a removal could never persist anyway.
|
||||
var g = Assert.Single(BindingGroupBuilder.Build(new[]
|
||||
{
|
||||
Row("M.A", "A", 1, "Old.A"),
|
||||
Row("M.B", "B", 2, "Old.B"),
|
||||
Row("M.C", "C", null, null),
|
||||
}));
|
||||
var changes = BindingGroupBuilder.ApplyObject(g, connectionId: null, objectPath: "New");
|
||||
Assert.Equal(new int?[] { 1, 2, null }, changes.Select(c => c.ConnectionId));
|
||||
Assert.All(changes, c => Assert.StartsWith("New.", c.Override!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InferredObject_MixedWhenSomeMembersStillOnBareDefault()
|
||||
{
|
||||
// M.B has no override and its default ("B") is not "<prefix>.B" — the gate
|
||||
// will reject it, so the group must read mixed rather than unified on "O".
|
||||
var rows = new[] { Row("M.A", "A", 1, "O.A"), Row("M.B", "B", 1, null) };
|
||||
var g = Assert.Single(BindingGroupBuilder.Build(rows));
|
||||
Assert.Null(g.InferredObject);
|
||||
Assert.True(g.IsObjectMixed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InferredObject_UsesEffectiveReference_DefaultThatCarriesPrefixIsNotMixed()
|
||||
{
|
||||
var rows = new[] { Row("M.A", "A", 1, "O.A"), Row("M.B", "B", 1, null) with { DefaultReference = "O.B" } };
|
||||
var g = Assert.Single(BindingGroupBuilder.Build(rows));
|
||||
Assert.Equal("O", g.InferredObject);
|
||||
Assert.False(g.IsObjectMixed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InferredObject_NoOverrides_InfersFromDefaultsWhenTheyShareAPrefix()
|
||||
{
|
||||
var rows = new[] { Row("A", "Z28061.A", 1, null), Row("B", "Z28061.B", 1, null) };
|
||||
var g = Assert.Single(BindingGroupBuilder.Build(rows));
|
||||
Assert.Equal("Z28061", g.InferredObject);
|
||||
Assert.False(g.IsObjectMixed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsUnbound_WhenConnectionIdIsNotAKnownConnection()
|
||||
{
|
||||
var rows = new[] { Row("M.A", "A", 99, "O.A") };
|
||||
var g = Assert.Single(BindingGroupBuilder.Build(rows, knownConnectionIds: new[] { 1, 2 }));
|
||||
Assert.Equal(1, g.UnboundCount);
|
||||
Assert.Equal(BindingConnectionState.None, g.ConnectionState);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user