Skip to content

Commit 37a290d

Browse files
committed
Updated Builder to allow customisation of factory
1 parent 8f0dc5f commit 37a290d

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

TestStack.Dossier/Builder.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace TestStack.Dossier
1+
using TestStack.Dossier.Factories;
2+
3+
namespace TestStack.Dossier
24
{
35
/// <summary>
46
/// A stand-alone class for building objects on the fly.
@@ -7,13 +9,28 @@
79
public class Builder<T> : TestDataBuilder<T, Builder<T>>
810
where T : class
911
{
12+
/// <inheritdoc />
13+
public Builder()
14+
: this(new AllPropertiesFactory())
15+
{
16+
17+
}
18+
19+
/// <inheritdoc />
20+
public Builder(IFactory factory)
21+
: base(factory) { }
22+
1023
/// <summary>
1124
/// Initialises a new Builder.
1225
/// </summary>
1326
/// <returns>Returns a new instance of a Builder for the type of T</returns>
14-
public static Builder<T> CreateNew()
27+
public static Builder<T> CreateNew(IFactory factory = null)
1528
{
16-
return new Builder<T>();
29+
if (factory == null)
30+
{
31+
factory = new AllPropertiesFactory();
32+
}
33+
return new Builder<T>(factory);
1734
}
1835
}
1936
}

0 commit comments

Comments
 (0)