mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
Add pathing contract loader validation scaffold
This commit is contained in:
parent
aefc7235ee
commit
9fe376a3bb
6 changed files with 376 additions and 52 deletions
|
|
@ -13,17 +13,202 @@ public sealed class PathPlanningContractTests
|
|||
|
||||
PathingPlannerContract contract = store.GetPlanner("manager-accepted-ascend-chain");
|
||||
|
||||
Assert.Equal("manager-accepted-ascend-chain", contract.ScenarioId);
|
||||
Assert.Equal(PathStatus.Success, contract.ExpectedStatus);
|
||||
Assert.Equal(6, contract.Segments.Length);
|
||||
Assert.Equal(6, contract.Segments.Count);
|
||||
|
||||
PathingPlannerSegmentContract firstSegment = contract.Segments[0];
|
||||
Assert.Equal(MoveType.Diagonal, firstSegment.Move);
|
||||
Assert.Equal(new PathingBlock(171, 80, 160), firstSegment.From);
|
||||
Assert.Equal(new PathingBlock(172, 80, 161), firstSegment.To);
|
||||
Assert.Equal(MoveType.Diagonal, firstSegment.MoveType);
|
||||
Assert.Equal(new PathingBlock(171, 80, 160), firstSegment.StartBlock);
|
||||
Assert.Equal(new PathingBlock(172, 80, 161), firstSegment.EndBlock);
|
||||
|
||||
PathingPlannerSegmentContract lastSegment = contract.Segments[5];
|
||||
Assert.Equal(MoveType.Ascend, lastSegment.Move);
|
||||
Assert.Equal(new PathingBlock(176, 82, 162), lastSegment.From);
|
||||
Assert.Equal(new PathingBlock(177, 83, 162), lastSegment.To);
|
||||
Assert.Equal(MoveType.Ascend, lastSegment.MoveType);
|
||||
Assert.Equal(new PathingBlock(176, 82, 162), lastSegment.StartBlock);
|
||||
Assert.Equal(new PathingBlock(177, 83, 162), lastSegment.EndBlock);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_ManagerAcceptedAscendChain_LoadsTimingScaffoldShape()
|
||||
{
|
||||
var store = PathingContractStore.LoadFromRepositoryRoot();
|
||||
|
||||
PathingTimingBudget timing = store.GetTiming("manager-accepted-ascend-chain");
|
||||
|
||||
Assert.Equal("manager-accepted-ascend-chain", timing.ScenarioId);
|
||||
Assert.Equal(6, timing.Segments.Count);
|
||||
Assert.True(timing.ExpectedTotalTicks <= timing.MaxTotalTicks);
|
||||
|
||||
PathingSegmentTimingBudget firstSegment = timing.Segments[0];
|
||||
Assert.Equal(MoveType.Diagonal, firstSegment.MoveType);
|
||||
Assert.True(firstSegment.ExpectedTicks <= firstSegment.MaxTicks);
|
||||
|
||||
foreach (PathingSegmentTimingBudget segment in timing.Segments)
|
||||
{
|
||||
Assert.True(segment.ExpectedTicks <= segment.MaxTicks);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadFromJson_RejectsTimingSegment_WhenExpectedExceedsMax()
|
||||
{
|
||||
const string plannerJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "manager-accepted-ascend-chain",
|
||||
"expectedStatus": "Success",
|
||||
"segments": [
|
||||
{
|
||||
"moveType": "Diagonal",
|
||||
"startBlock": { "x": 171, "y": 80, "z": 160 },
|
||||
"endBlock": { "x": 172, "y": 80, "z": 161 }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
const string timingJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "manager-accepted-ascend-chain",
|
||||
"expectedTotalTicks": 1,
|
||||
"maxTotalTicks": 1,
|
||||
"segments": [
|
||||
{ "moveType": "Diagonal", "expectedTicks": 2, "maxTicks": 1 }
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
|
||||
InvalidDataException error = Assert.Throws<InvalidDataException>(
|
||||
() => PathingContractStore.LoadFromJson(plannerJson, timingJson));
|
||||
Assert.Contains("manager-accepted-ascend-chain", error.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadFromJson_Rejects_WhenPlannerAndTimingScenarioSetsMismatch()
|
||||
{
|
||||
const string plannerJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "planner-only",
|
||||
"expectedStatus": "Success",
|
||||
"segments": [
|
||||
{
|
||||
"moveType": "Traverse",
|
||||
"startBlock": { "x": 0, "y": 80, "z": 0 },
|
||||
"endBlock": { "x": 1, "y": 80, "z": 0 }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
const string timingJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "timing-only",
|
||||
"expectedTotalTicks": 1,
|
||||
"maxTotalTicks": 1,
|
||||
"segments": [
|
||||
{ "moveType": "Traverse", "expectedTicks": 1, "maxTicks": 1 }
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
|
||||
InvalidDataException error = Assert.Throws<InvalidDataException>(
|
||||
() => PathingContractStore.LoadFromJson(plannerJson, timingJson));
|
||||
Assert.Contains("planner-only", error.Message);
|
||||
Assert.Contains("timing-only", error.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadFromJson_RejectsDuplicatePlannerScenarioId()
|
||||
{
|
||||
const string plannerJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "dup",
|
||||
"expectedStatus": "Success",
|
||||
"segments": [
|
||||
{
|
||||
"moveType": "Traverse",
|
||||
"startBlock": { "x": 0, "y": 80, "z": 0 },
|
||||
"endBlock": { "x": 1, "y": 80, "z": 0 }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"scenarioId": "dup",
|
||||
"expectedStatus": "Success",
|
||||
"segments": [
|
||||
{
|
||||
"moveType": "Traverse",
|
||||
"startBlock": { "x": 1, "y": 80, "z": 0 },
|
||||
"endBlock": { "x": 2, "y": 80, "z": 0 }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
const string timingJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "dup",
|
||||
"expectedTotalTicks": 1,
|
||||
"maxTotalTicks": 1,
|
||||
"segments": [
|
||||
{ "moveType": "Traverse", "expectedTicks": 1, "maxTicks": 1 }
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
|
||||
InvalidDataException error = Assert.Throws<InvalidDataException>(
|
||||
() => PathingContractStore.LoadFromJson(plannerJson, timingJson));
|
||||
Assert.Contains("Duplicate planner contract scenario id", error.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadFromJson_Rejects_WhenPlannerAndTimingMoveSequenceDiffer()
|
||||
{
|
||||
const string plannerJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "sequence-mismatch",
|
||||
"expectedStatus": "Success",
|
||||
"segments": [
|
||||
{
|
||||
"moveType": "Traverse",
|
||||
"startBlock": { "x": 0, "y": 80, "z": 0 },
|
||||
"endBlock": { "x": 1, "y": 80, "z": 0 }
|
||||
},
|
||||
{
|
||||
"moveType": "Ascend",
|
||||
"startBlock": { "x": 1, "y": 80, "z": 0 },
|
||||
"endBlock": { "x": 2, "y": 81, "z": 0 }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
const string timingJson = """
|
||||
[
|
||||
{
|
||||
"scenarioId": "sequence-mismatch",
|
||||
"expectedTotalTicks": 2,
|
||||
"maxTotalTicks": 2,
|
||||
"segments": [
|
||||
{ "moveType": "Traverse", "expectedTicks": 1, "maxTicks": 1 },
|
||||
{ "moveType": "Diagonal", "expectedTicks": 1, "maxTicks": 1 }
|
||||
]
|
||||
}
|
||||
]
|
||||
""";
|
||||
|
||||
InvalidDataException error = Assert.Throws<InvalidDataException>(
|
||||
() => PathingContractStore.LoadFromJson(plannerJson, timingJson));
|
||||
Assert.Contains("sequence-mismatch", error.Message);
|
||||
Assert.Contains("segment 1", error.Message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue