test(r2-06): pin 0.2.0 Boolean->Int1 explicit-presence (HasDataType) provisioning (06/U-7)

This commit is contained in:
Joseph Doherty
2026-07-13 09:58:07 -04:00
parent b77bbd13b7
commit dc2f3fa970
2 changed files with 30 additions and 1 deletions
@@ -51,7 +51,7 @@
{
"id": "T7",
"subject": "U-7 pin: GatewayTagProvisionerTests Boolean_definition_carries_explicit_Int1_presence (asserts HistorianDataType.Int1 AND HasDataType — 0.2.0 proto3-optional presence witness; pin, no RED phase)",
"status": "pending",
"status": "completed",
"blockedBy": []
},
{
@@ -31,6 +31,35 @@ public sealed class GatewayTagProvisionerTests
Assert.Equal(0, result.Skipped);
}
/// <summary>
/// archreview 06/U-7 — pins the 0.2.0 Boolean→Int1 provisioning semantics at TWO levels. The
/// 0.1.0→0.2.0 client bump made <c>HistorianTagDefinition.DataType</c> proto3-optional (explicit
/// presence): under 0.1.0 the provisioner's <c>Int1</c> (wire 0) was indistinguishable from unset,
/// so the gateway defaulted Boolean tags to Float; under 0.2.0 the same call carries explicit
/// presence and provisions Int1 (the intended behavior). Asserting BOTH the mapped type AND
/// <c>HasDataType</c> compile-pins the package floor (the <c>HasDataType</c>/<c>ClearDataType</c>
/// members exist only on the 0.2.0 proto3-optional contract — a downgrade breaks the build) and
/// assert-pins that the provisioner always sends explicit presence (a future contract change that
/// stopped sending it would break the assert). This is a pin, not a fix — it passes on current code.
/// </summary>
[Fact]
public async Task Boolean_definition_carries_explicit_Int1_presence()
{
var fake = new FakeHistorianGatewayClient { EnsureTagsResult = new TagOperationResults() };
var p = Provisioner(fake);
await p.EnsureTagsAsync(
new[] { new HistorianTagProvisionRequest("Pump1.Run", DriverDataType.Boolean, null, null) },
TestContext.Current.CancellationToken);
var defs = fake.LastEnsureDefinitions!;
Assert.Single(defs);
Assert.Equal(HistorianDataType.Int1, defs[0].DataType);
// 0.2.0 proto3-optional presence witness — explicit presence is what flips the gateway from its
// SDK-default Float to the requested Int1. Without this, a Boolean tag would provision as Float.
Assert.True(defs[0].HasDataType);
}
[Fact]
public async Task Maps_metadata_and_coalesces_null_metadata_to_empty()
{