test(drivers): tighten driver-page converter guard + clarify S7 numeric case
Code-review follow-ups: the page-coverage test now asserts every *DriverPage declares a _jsonOpts serializer (so a new page that serialises config a different way fails the guard, not just converter removal); clarify that 40 == (int)S7CpuType.S71500 in the numeric-throws test.
This commit is contained in:
@@ -53,9 +53,17 @@ public sealed class DriverPageJsonConverterTests
|
||||
"enum config fields serialise as numbers and the string-typed driver factory throws on parse.");
|
||||
}
|
||||
|
||||
/// <summary>Sanity-check that reflection actually discovered the full driver-page fleet (so a
|
||||
/// rename/move can't silently shrink the guarded set to zero).</summary>
|
||||
/// <summary>Enforces that EVERY concrete <c>*DriverPage</c> routes config serialization through a
|
||||
/// <c>_jsonOpts</c> field — otherwise a new page that serialised config a different way would slip
|
||||
/// past the converter guard above. Also a floor check so a rename can't silently shrink the set.</summary>
|
||||
[Fact]
|
||||
public void All_known_driver_pages_are_covered()
|
||||
=> DriverPageTypes.Count.ShouldBeGreaterThanOrEqualTo(9);
|
||||
public void Every_driver_page_uses_a_guarded_jsonOpts_serializer()
|
||||
{
|
||||
var allDriverPages = typeof(S7DriverPage).Assembly.GetTypes()
|
||||
.Where(t => t.Name.EndsWith("DriverPage", StringComparison.Ordinal) && !t.IsAbstract)
|
||||
.ToList();
|
||||
allDriverPages.Count.ShouldBeGreaterThanOrEqualTo(9, "reflection should discover the full driver-page fleet");
|
||||
DriverPageTypes.Count.ShouldBe(allDriverPages.Count,
|
||||
"every *DriverPage must declare a _jsonOpts config serializer so the string-enum converter guard covers it");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user