fix(posts): keep CI Fiber material codes case-insensitive after reload

System.Text.Json rebuilds MaterialCodes with the default ordinal comparer,
so a saved config matched 'Mild Steel' but not 'mild steel' and silently
fell back to the default code. The setter now re-keys assigned maps
case-insensitively.
This commit is contained in:
aj
2026-09-28 18:21:07 -04:00
parent 35aa64fe4e
commit 9ec28add80
2 changed files with 47 additions and 3 deletions
@@ -309,4 +309,24 @@ public class CIFiberPostProcessorTests
Assert.Contains("G0X50Y50", output);
Assert.Contains("V.E.R3=1", output);
}
[Fact]
public void MaterialCodes_MatchIgnoringCase_AfterJsonReload()
{
var options = new System.Text.Json.JsonSerializerOptions();
var json = System.Text.Json.JsonSerializer.Serialize(
new CIFiberPostConfig
{
MaterialCodes = new() { ["Stainless"] = "SSN" },
DefaultMaterialCode = "MSN",
},
options
);
var config = System.Text.Json.JsonSerializer.Deserialize<CIFiberPostConfig>(json, options)!;
Assert.Equal("SSN", config.ResolveMaterialCode("stainless"));
Assert.Equal("SSN", config.ResolveMaterialCode(" STAINLESS "));
Assert.Equal("MSN", config.ResolveMaterialCode("Aluminum"));
}
}