Skip to content

Commit b89dac3

Browse files
Makes the Set function on NTestDataBuilder fluent
I've noticed we're writing a lot of boiler plate in our derived builders, things that just forward to Set and return themselves. This changes the Set method provided by the base class to be a fluent interface. This allows each of the provided functions in your derived builder class to be ones which have some extra constraints they need to enforce (uniqueness, formatting, whatever) and reduces boiler plate when it doesn't matter.
1 parent a803219 commit b89dac3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

NTestDataBuilder/TestDataBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ protected virtual void AlterProxy(TObject proxy) {}
7575
/// <typeparam name="TValue">The type of the property</typeparam>
7676
/// <param name="property">A lambda expression specifying the property to record a value for</param>
7777
/// <param name="value">The value to record</param>
78-
public void Set<TValue>(Expression<Func<TObject, TValue>> property, TValue value)
78+
public TBuilder Set<TValue>(Expression<Func<TObject, TValue>> property, TValue value)
7979
{
8080
_properties[GetPropertyName(property)] = value;
81+
return (TBuilder)this;
8182
}
8283

8384
/// <summary>

0 commit comments

Comments
 (0)