feat(mtconnect): authoring DataType warning + loud ignored-DeviceName warning (#613 slice)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -295,4 +295,37 @@ public sealed class MTConnectTagConfigModelTests
|
||||
[InlineData("""{"fullName":"x","driverDataType":8,"dataType":"Int32"}""")]
|
||||
public void Validate_rejects_a_driverDataType_written_as_an_unquoted_number(string json)
|
||||
=> MTConnectTagConfigModel.FromJson(json).Validate().ShouldNotBeNull().ShouldContain("8");
|
||||
|
||||
private static MTConnectTagConfigModel Stamped(string category, string type, string dataType)
|
||||
=> MTConnectTagConfigModel.FromJson(
|
||||
$"{{\"fullName\":\"x\",\"dataType\":\"{dataType}\",\"mtCategory\":\"{category}\",\"mtType\":\"{type}\"}}");
|
||||
|
||||
[Theory]
|
||||
[InlineData("SAMPLE", "POSITION", "Boolean")] // numeric inferred, non-numeric declared
|
||||
[InlineData("SAMPLE", "POSITION", "Int32")] // fractional readings cannot fit
|
||||
[InlineData("EVENT", "EXECUTION", "Float64")] // text inferred, numeric declared
|
||||
[InlineData("CONDITION", "TEMPERATURE", "Int32")]
|
||||
public void Warnings_flags_a_declared_type_that_cannot_hold_the_inferred_one_without_blocking(
|
||||
string category, string type, string dataType)
|
||||
{
|
||||
var m = Stamped(category, type, dataType);
|
||||
|
||||
m.Warnings().ShouldHaveSingleItem().ShouldContain(dataType);
|
||||
m.Validate().ShouldBeNull(); // advisory: never blocks
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("SAMPLE", "POSITION", "Float64")]
|
||||
[InlineData("SAMPLE", "POSITION", "String")] // text holds anything
|
||||
[InlineData("EVENT", "EXECUTION", "String")]
|
||||
[InlineData("EVENT", "PART_COUNT", "Int64")]
|
||||
[InlineData("EVENT", "PART_COUNT", "Float64")]
|
||||
public void Warnings_is_quiet_when_the_declared_type_holds_the_inferred_one(
|
||||
string category, string type, string dataType)
|
||||
=> Stamped(category, type, dataType).Warnings().ShouldBeEmpty();
|
||||
|
||||
[Fact]
|
||||
public void Warnings_is_a_noop_without_probe_metadata()
|
||||
=> MTConnectTagConfigModel.FromJson("{\"fullName\":\"x\",\"dataType\":\"Boolean\"}")
|
||||
.Warnings().ShouldBeEmpty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user