mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
test: lock short route planner and timing contracts
This commit is contained in:
parent
b9bff02107
commit
ba1dc32ccb
9 changed files with 339 additions and 4 deletions
|
|
@ -116,8 +116,11 @@ public sealed class PathingContractStore
|
|||
if (string.IsNullOrWhiteSpace(contract.ScenarioId))
|
||||
throw new InvalidDataException("Planner contract has blank scenario id.");
|
||||
|
||||
if (contract.Segments is null || contract.Segments.Count == 0)
|
||||
throw new InvalidDataException($"Planner contract '{contract.ScenarioId}' must contain at least one segment.");
|
||||
if (contract.Segments is null)
|
||||
throw new InvalidDataException($"Planner contract '{contract.ScenarioId}' has null segments.");
|
||||
|
||||
if (contract.ExpectedStatus != PathStatus.Failed && contract.Segments.Count == 0)
|
||||
throw new InvalidDataException($"Planner contract '{contract.ScenarioId}' must contain at least one segment unless the expected status is Failed.");
|
||||
|
||||
var normalizedSegments = new List<PathingPlannerSegmentContract>(contract.Segments.Count);
|
||||
for (int i = 0; i < contract.Segments.Count; i++)
|
||||
|
|
@ -134,8 +137,8 @@ public sealed class PathingContractStore
|
|||
if (string.IsNullOrWhiteSpace(budget.ScenarioId))
|
||||
throw new InvalidDataException("Timing budget has blank scenario id.");
|
||||
|
||||
if (budget.Segments is null || budget.Segments.Count == 0)
|
||||
throw new InvalidDataException($"Timing budget '{budget.ScenarioId}' must contain at least one segment.");
|
||||
if (budget.Segments is null)
|
||||
throw new InvalidDataException($"Timing budget '{budget.ScenarioId}' has null segments.");
|
||||
|
||||
if (budget.ExpectedTotalTicks < 0 || budget.MaxTotalTicks < 0)
|
||||
throw new InvalidDataException($"Timing budget '{budget.ScenarioId}' total ticks must be nonnegative.");
|
||||
|
|
@ -143,6 +146,9 @@ public sealed class PathingContractStore
|
|||
if (budget.ExpectedTotalTicks > budget.MaxTotalTicks)
|
||||
throw new InvalidDataException($"Timing budget '{budget.ScenarioId}' has ExpectedTotalTicks greater than MaxTotalTicks.");
|
||||
|
||||
if (budget.Segments.Count == 0 && (budget.ExpectedTotalTicks != 0 || budget.MaxTotalTicks != 0))
|
||||
throw new InvalidDataException($"Timing budget '{budget.ScenarioId}' must use zero totals when it has no segments.");
|
||||
|
||||
var normalizedSegments = new List<PathingSegmentTimingBudget>(budget.Segments.Count);
|
||||
for (int i = 0; i < budget.Segments.Count; i++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue