Skip to content

Commit

Permalink
Updated Builder to allow customisation of factory
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhelan committed May 3, 2015
1 parent 8f0dc5f commit 37a290d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions TestStack.Dossier/Builder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace TestStack.Dossier
using TestStack.Dossier.Factories;

namespace TestStack.Dossier
{
/// <summary>
/// A stand-alone class for building objects on the fly.
Expand All @@ -7,13 +9,28 @@
public class Builder<T> : TestDataBuilder<T, Builder<T>>
where T : class
{
/// <inheritdoc />
public Builder()
: this(new AllPropertiesFactory())
{

}

/// <inheritdoc />
public Builder(IFactory factory)
: base(factory) { }

/// <summary>
/// Initialises a new Builder.
/// </summary>
/// <returns>Returns a new instance of a Builder for the type of T</returns>
public static Builder<T> CreateNew()
public static Builder<T> CreateNew(IFactory factory = null)
{
return new Builder<T>();
if (factory == null)
{
factory = new AllPropertiesFactory();
}
return new Builder<T>(factory);
}
}
}

0 comments on commit 37a290d

Please sign in to comment.