File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -30,5 +30,19 @@ public void GivenBuilderWithMethodCalls_WhenCallingBuild_ThenReturnAnObjectWithT
3030 Assert . That ( customer . LastName , Is . EqualTo ( "Kocaj" ) ) ;
3131 Assert . That ( customer . YearJoined , Is . EqualTo ( 2010 ) ) ;
3232 }
33+
34+ [ Test ]
35+ public void GivenBuilder_WhenCallingSet_ShouldOverrideValues ( )
36+ {
37+ var builder = new CustomerBuilder ( )
38+ . Set ( x => x . FirstName , "Pi" )
39+ . Set ( x => x . LastName , "Lanningham" )
40+ . Set ( x => x . YearJoined , 2014 ) ;
41+
42+ var customer = builder . Build ( ) ;
43+ Assert . That ( customer . FirstName , Is . EqualTo ( "Pi" ) ) ;
44+ Assert . That ( customer . LastName , Is . EqualTo ( "Lanningham" ) ) ;
45+ Assert . That ( customer . YearJoined , Is . EqualTo ( 2014 ) ) ;
46+ }
3347 }
3448}
Original file line number Diff line number Diff 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 this as TBuilder ;
8182 }
8283
8384 /// <summary>
You can’t perform that action at this time.
0 commit comments