Finish rewrite task list
This commit is contained in:
@@ -121,6 +121,18 @@ public sealed class SimulationEngineTests
|
||||
Assert.Contains(report.Errors, error => error.Message.Contains("Ambiguous junction flow", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidatorRejectsJunctionWithoutTwoOrThreeOutflows()
|
||||
{
|
||||
var level = BuildJunctionLevel(2);
|
||||
level = level.SetUnderground(new(3, 3), ECarrierType.Fuel, new());
|
||||
|
||||
var report = new LevelValidator().Validate(level);
|
||||
|
||||
Assert.False(report.IsValid);
|
||||
Assert.Contains(report.Errors, error => error.Message.Contains("one incoming branch and two or three outgoing branches", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NonJunctionCellsAcceptBestFlowFromMultipleSourcePaths()
|
||||
{
|
||||
@@ -336,6 +348,33 @@ public sealed class SimulationEngineTests
|
||||
Assert.Equal(EPropType.Flow, loaded.GetProp(new(2, 2)).Type);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LevelSerializationRoundTripsRuleEventsDoorsAndElectricityLeakFaces()
|
||||
{
|
||||
var level = BuildReadyLevel();
|
||||
level = level.SetTerrain(new(6, 4), ECellTerrain.Wall);
|
||||
level = level.SetUnderground(new(6, 4), ECarrierType.Electricity, new() { State = EUndergroundState.Leaking }) with {
|
||||
Doors = [new() { A = new(5, 3), B = new(5, 4), State = EDoorState.Closed }],
|
||||
Leaks = [new() { Carrier = ECarrierType.Electricity, UndergroundPosition = new(6, 4), AccessPosition = new(6, 3) }],
|
||||
RuleEvents = [
|
||||
new() {
|
||||
Id = "authored",
|
||||
Phase = ERuleEventPhase.EndOfTurn,
|
||||
Predicates = [new() { Kind = ERulePredicateKind.TurnAtLeast, Turn = 2 }],
|
||||
Effects = [new() { Kind = ERuleEffectKind.EmitWarning, Message = "serialized" }]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var loaded = LevelSerializer.Deserialize(LevelSerializer.Serialize(level));
|
||||
|
||||
Assert.Single(loaded.Doors);
|
||||
Assert.Single(loaded.Leaks);
|
||||
Assert.Single(loaded.RuleEvents);
|
||||
Assert.Equal(new(6, 3), loaded.Leaks[0].AccessPosition);
|
||||
Assert.Equal("authored", loaded.RuleEvents[0].Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LevelSerializationRejectsOldSchema()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user