Tighten editor validation coverage

This commit is contained in:
2026-05-14 10:29:36 +02:00
parent 6decf2a9d2
commit ec8761f4e8
5 changed files with 50 additions and 5 deletions

View File

@@ -92,6 +92,7 @@ public sealed class LevelEditorTests
Assert.Equal(EPropType.SprinklerControl, valve.GetProp(new(1, 2)).Type);
Assert.Equal(EPropType.SprinklerValve, valve.GetProp(new(2, 2)).Type);
Assert.Equal(new(2, 2), valve.GetProp(new(1, 2)).LinkedPosition);
Assert.Equal(new(2, 1), valve.GetProp(new(2, 2)).OutletPosition);
}

View File

@@ -403,6 +403,20 @@ public sealed class SimulationEngineTests
Assert.Contains(report.Errors, error => error.Message.Contains("Wall cell", StringComparison.Ordinal));
}
[Fact]
public void ValidatorRejectsIsolationValveOnMultipleCarriers()
{
var level = LevelState.Create("Invalid valve", 5, 5);
level = level.SetUnderground(new(2, 2), ECarrierType.Fuel, new() { State = EUndergroundState.Intact });
level = level.SetUnderground(new(2, 2), ECarrierType.Water, new() { State = EUndergroundState.Intact });
level = level.SetProp(new(2, 2), new() { Type = EPropType.IsolationValve, Carrier = ECarrierType.Fuel });
var report = new LevelValidator().Validate(level);
Assert.False(report.IsValid);
Assert.Contains(report.Errors, error => error.Message.Contains("exactly one matching underground carrier", StringComparison.Ordinal));
}
[Fact]
public void LevelSerializationRoundTripsCurrentSchemaOnly()
{