Skip to content

Commit dcc7ebe

Browse files
committed
Merge pull request #13 from Tynamix/FEATURE_CreateMultiple
new api Create(int count)
2 parents 9ede763 + 31aa6b7 commit dcc7ebe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ObjectFiller/Filler.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ public T Create()
5858
return objectToFill;
5959
}
6060

61+
/// <summary>
62+
/// Creates multiple filled objects. Call this after you finished your setup with the FluentAPI and if you want
63+
/// to create several new objects. If you want to use a existing instance use the <see cref="Fill(T)"/> method.
64+
/// </summary>
65+
public IEnumerable<T> Create(int count)
66+
{
67+
for (int n = 0; n < count; n++)
68+
{
69+
T objectToFill = (T) CreateInstanceOfType(typeof (T), SetupManager.GetFor<T>());
70+
Fill(objectToFill);
71+
yield return objectToFill;
72+
}
73+
}
74+
6175
/// <summary>
6276
/// This will fill your instance of an object of type <see cref="T"/> and overrides the setup for the generation.
6377
/// Use this method if you don't wan't to use the FluentAPI

0 commit comments

Comments
 (0)