95 lines
3.8 KiB
C#
95 lines
3.8 KiB
C#
namespace ReactorMaintenance.Simulation.Tests;
|
|
|
|
public sealed class LevelEditorTests
|
|
{
|
|
[Fact]
|
|
public void DoorToolPlacesSingleFloorDoorProp()
|
|
{
|
|
var level = LevelState.Create("Door editor", 6, 6);
|
|
|
|
var next = LevelEditor.Apply(level, new(2, 2), new() { Tool = EEditorTool.Door });
|
|
|
|
Assert.Equal(EPropType.Door, next.GetProp(new(2, 2)).Type);
|
|
Assert.Equal(EDoorState.Closed, next.GetProp(new(2, 2)).DoorState);
|
|
}
|
|
|
|
[Fact]
|
|
public void ConsumerToolPlacesCarrierAgnosticConsumer()
|
|
{
|
|
var level = LevelState.Create("Consumer editor", 6, 6);
|
|
|
|
var next = LevelEditor.Apply(level, new(2, 2), new() { Tool = EEditorTool.Consumer, Carrier = ECarrierType.Fuel });
|
|
|
|
Assert.Equal(EPropType.Consumer, next.GetProp(new(2, 2)).Type);
|
|
Assert.Equal(EConsumerServiceState.Unknown, next.GetProp(new(2, 2)).FuelServiceState);
|
|
Assert.Equal(EConsumerServiceState.Unknown, next.GetProp(new(2, 2)).CoolantServiceState);
|
|
Assert.Equal(EConsumerServiceState.Unknown, next.GetProp(new(2, 2)).ElectricityServiceState);
|
|
}
|
|
|
|
[Fact]
|
|
public void ElectricityLeakUsesAuthoredWallAccessFace()
|
|
{
|
|
var level = LevelState.Create("Electricity leak editor", 6, 6);
|
|
level = level.SetTerrain(new(2, 2), ECellTerrain.Wall);
|
|
|
|
var next = LevelEditor.SetLeak(level, new(2, 2), new(2, 3), ECarrierType.Electricity);
|
|
var rejected = LevelEditor.SetLeak(next, new(2, 2), new(4, 4), ECarrierType.Electricity);
|
|
|
|
Assert.Single(next.Leaks);
|
|
Assert.Equal(new(2, 3), next.Leaks[0].AccessPosition);
|
|
Assert.Equal(EUndergroundState.Leaking, next.GetUnderground(new(2, 2), ECarrierType.Electricity).State);
|
|
Assert.Equal(next.Leaks, rejected.Leaks);
|
|
}
|
|
|
|
[Fact]
|
|
public void ElectricityLeakAccessCyclesAcrossAdjacentFloorFaces()
|
|
{
|
|
var level = LevelState.Create("Electricity leak editor", 6, 6);
|
|
level = level.SetTerrain(new(2, 2), ECellTerrain.Wall);
|
|
level = level.SetTerrain(new(2, 1), ECellTerrain.Wall);
|
|
level = LevelEditor.Apply(level, new(2, 2), new() { Tool = EEditorTool.Underground, Carrier = ECarrierType.Electricity });
|
|
|
|
var first = LevelEditor.CycleElectricityLeakAccess(level, new(2, 2));
|
|
var second = LevelEditor.CycleElectricityLeakAccess(first, new(2, 2));
|
|
|
|
Assert.Single(first.Leaks);
|
|
Assert.Equal(new(3, 2), first.Leaks[0].AccessPosition);
|
|
Assert.Single(second.Leaks);
|
|
Assert.Equal(new(2, 3), second.Leaks[0].AccessPosition);
|
|
}
|
|
|
|
[Fact]
|
|
public void ReactorControlToolCreatesUnboundReactorState()
|
|
{
|
|
var level = LevelState.Create("Reactor editor", 6, 6);
|
|
|
|
var next = LevelEditor.Apply(level, new(2, 2), new() { Tool = EEditorTool.ReactorControl });
|
|
|
|
Assert.Single(next.Reactors);
|
|
Assert.Equal(new(2, 2), next.Reactors[0].ControlPosition);
|
|
Assert.Equal(1, next.Reactors[0].ReactorId);
|
|
}
|
|
|
|
[Fact]
|
|
public void MoveOccupantMovesRobotToFloorDestination()
|
|
{
|
|
var level = LevelState.Create("Move editor", 6, 6) with { Robot = new() { Position = new(1, 1) } };
|
|
|
|
var next = LevelEditor.MoveOccupant(level, new(1, 1), new(3, 3));
|
|
|
|
Assert.Equal(new(3, 3), next.Robot.Position);
|
|
}
|
|
|
|
[Fact]
|
|
public void MoveOccupantMovesPropAndUpdatesReactorControlPosition()
|
|
{
|
|
var level = LevelState.Create("Move editor", 6, 6);
|
|
level = LevelEditor.Apply(level, new(1, 1), new() { Tool = EEditorTool.ReactorControl });
|
|
|
|
var next = LevelEditor.MoveOccupant(level, new(1, 1), new(3, 3));
|
|
|
|
Assert.Equal(EPropType.None, next.GetProp(new(1, 1)).Type);
|
|
Assert.Equal(EPropType.ReactorControl, next.GetProp(new(3, 3)).Type);
|
|
Assert.Equal(new(3, 3), next.Reactors[0].ControlPosition);
|
|
}
|
|
} |