Skip to content

Commit

Permalink
Issue 1562 (exercism#1562): Correct unit test "Robot_names_are_unique…
Browse files Browse the repository at this point in the history
…" to keep a reference to each generated robot.
  • Loading branch information
HugoRoss committed Aug 6, 2021
1 parent 7820866 commit f007319
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions exercises/practice/robot-name/RobotNameTests.cs
Expand Up @@ -42,11 +42,15 @@ public void After_reset_the_name_is_valid()
[Fact(Skip = "Remove this Skip property to run this test")]
public void Robot_names_are_unique()
{
var names = new HashSet<string>();
for (int i = 0; i < 10_000; i++) {
const int robotsCount = 10_000;
var robots = new List<Robot>(robotsCount); //Needed to keep a reference to the robots as IDs of recycled robots may be re-issued
var names = new HashSet<string>(robotsCount);
for (int i = 0; i < robotsCount; i++) {
var robot = new Robot();
robots.Add(robot);
Assert.True(names.Add(robot.Name));
Assert.Matches(@"^[A-Z]{2}\d{3}$", robot.Name);
}
}

}

0 comments on commit f007319

Please sign in to comment.