test(template): M2.8 review nits — stale-binding comment + stale-ID & inert-check tests (#23)

Add code comments in ValidateConnectionBindingCompleteness explaining
that the unbound-attribute branch also covers the silently-dropped
stale-binding case (cross-reference FlatteningService.ApplyConnectionBindings),
and that the `continue` skips the exists-at-site check for unbound attrs.

Add two new tests:
- FlatteningPipelineConnectionBindingTests: stale DataConnectionId (999)
  not present in site connections → flattener drops it silently →
  validator reports ConnectionBinding Error, IsValid false.
- ValidationServiceTests: enforce:true + siteConnectionNames:null on a
  properly-bound attribute → no ConnectionBinding error (exists-at-site
  check stays inert when site set is not supplied).
This commit is contained in:
Joseph Doherty
2026-06-16 05:34:56 -04:00
parent 3b79b896cf
commit 21b801b71f
3 changed files with 65 additions and 0 deletions
@@ -298,6 +298,36 @@ public class ValidationServiceTests
Assert.False(result.IsValid);
}
[Fact]
public void Validate_BoundAttributeWithNoSiteSet_DeployTime_ExistsAtSiteCheckIsInert()
{
// M2.8 (#23): when siteConnectionNames is null the "exists at site" half of the
// binding check stays inert — a properly-bound data-sourced attribute must NOT
// produce a ConnectionBinding error, even under deploy-time enforcement.
// This pins the contract: passing enforce:true + siteConnectionNames:null is safe
// (e.g. when the caller doesn't have a site connection set available yet).
var config = new FlattenedConfiguration
{
InstanceUniqueName = "Instance1",
Attributes =
[
new ResolvedAttribute
{
CanonicalName = "Temp",
DataType = "Double",
DataSourceReference = "ns=2;s=Temp",
BoundDataConnectionId = 7,
BoundDataConnectionName = "PlantBus"
}
]
};
var result = _sut.Validate(config, enforceConnectionBindings: true, siteConnectionNames: null);
Assert.DoesNotContain(result.Errors, e => e.Category == ValidationCategory.ConnectionBinding);
Assert.True(result.IsValid);
}
[Fact]
public void Validate_EmptyConfig_ReturnsWarning()
{