mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Merge pull request #35 from BinaryAlley/bugfix/fixes-flaky-unit-test-nested-directory-fixture
Fixes flaky unit test nested directory fixture
This commit is contained in:
1 file changed
+9
-3
+9
-3
@@ -98,12 +98,18 @@ public class DirectoryFixture
|
|||||||
private Directory CreateNestedDirectory(int currentDepth, int maxDepth, int maxChildrenPerDirectory)
|
private Directory CreateNestedDirectory(int currentDepth, int maxDepth, int maxChildrenPerDirectory)
|
||||||
{
|
{
|
||||||
List<FileSystemItem> childItems = [];
|
List<FileSystemItem> childItems = [];
|
||||||
|
// ensure we create at least one child if we haven't reached max depth
|
||||||
if (currentDepth < maxDepth)
|
if (currentDepth < maxDepth)
|
||||||
{
|
{
|
||||||
int childCount = _faker.Random.Int(0, maxChildrenPerDirectory);
|
// force at least 1 child, up to maxChildrenPerDirectory
|
||||||
|
int childCount = _faker.Random.Int(1, maxChildrenPerDirectory);
|
||||||
for (int i = 0; i < childCount; i++)
|
for (int i = 0; i < childCount; i++)
|
||||||
childItems.Add(CreateNestedDirectory(currentDepth + 1, maxDepth, maxChildrenPerDirectory));
|
{
|
||||||
|
Directory childDirectory = CreateNestedDirectory(currentDepth + 1, maxDepth, maxChildrenPerDirectory);
|
||||||
|
ErrorOr<Updated> addResult = childDirectory.SetParent(childDirectory);
|
||||||
|
if (!addResult.IsError)
|
||||||
|
childItems.Add(childDirectory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CreateDirectory(childItems: childItems);
|
return CreateDirectory(childItems: childItems);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user