Skip to content

Commit

Permalink
fix bug in span equipment specification validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jesper-dax committed Feb 16, 2021
1 parent e4cf52d commit 7feb848
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,23 @@ private static void ValidateSpanStructureLevelAndPosition(SpanEquipmentSpecifica

while (childsToCheck.Length != 0)
{
List<SpanStructureTemplate> nextLevelChildsToCheck = new List<SpanStructureTemplate>();

foreach (var childTemplate in childsToCheck)
{
if (childTemplate.Level != expectedChildLevel)
throw new ArgumentException($"Expected level: {childTemplate.Level} in template referencing span structure specification: {childTemplate.SpanStructureSpecificationId}");
throw new ArgumentException($"Expected level: {expectedChildLevel} in template referencing span structure specification: {childTemplate.SpanStructureSpecificationId}");

if (levelPositionUsed.Contains((childTemplate.Level, childTemplate.Position)))
throw new ArgumentException($"Level {childTemplate.Level} Position {childTemplate.Position} in template referencing span structure specification: {childTemplate.SpanStructureSpecificationId} is used more than once. Must be unique.");

levelPositionUsed.Add((childTemplate.Level, childTemplate.Position));

nextLevelChildsToCheck.AddRange(childTemplate.ChildTemplates);
}

childsToCheck = nextLevelChildsToCheck.ToArray();

expectedChildLevel++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public async void AddValidMultiLevelSpanEquipmentSpecification_ShouldSucceed()
var spanEquipmentSpecification = new SpanEquipmentSpecification(Guid.NewGuid(), "Conduit", "Ø50 2x12",
new SpanStructureTemplate(outerConduitSpanStructureSpec1.Id, 1, 1,
new SpanStructureTemplate[] {
new SpanStructureTemplate(innerConduitSpanStructureSpec1.Id, 2, 1, Array.Empty<SpanStructureTemplate>()),
new SpanStructureTemplate(innerConduitSpanStructureSpec2.Id, 2, 2, Array.Empty<SpanStructureTemplate>())
}
)
)
Expand Down

0 comments on commit 7feb848

Please sign in to comment.