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 @@ -31,5 +31,19 @@ public void GivenBuilderWithMethodCalls_WhenCallingBuild_ThenReturnAnObjectWithT
3131 customer . LastName . ShouldBe ( "Kocaj" ) ;
3232 customer . YearJoined . ShouldBe ( 2010 ) ;
3333 }
34+
35+ [ Test ]
36+ public void GivenBuilder_WhenCallingSet_ShouldOverrideValues ( )
37+ {
38+ var builder = new CustomerBuilder ( )
39+ . Set ( x => x . FirstName , "Pi" )
40+ . Set ( x => x . LastName , "Lanningham" )
41+ . Set ( x => x . YearJoined , 2014 ) ;
42+
43+ var customer = builder . Build ( ) ;
44+ Assert . That ( customer . FirstName , Is . EqualTo ( "Pi" ) ) ;
45+ Assert . That ( customer . LastName , Is . EqualTo ( "Lanningham" ) ) ;
46+ Assert . That ( customer . YearJoined , Is . EqualTo ( 2014 ) ) ;
47+ }
3448 }
3549}
Original file line number Diff line number Diff line change @@ -76,10 +76,11 @@ protected virtual void AlterProxy(TObject proxy) {}
7676 /// <typeparam name="TValue">The type of the property</typeparam>
7777 /// <param name="property">A lambda expression specifying the property to record a value for</param>
7878 /// <param name="value">The value to record</param>
79- protected TBuilder Set < TValue > ( Expression < Func < TObject , TValue > > property , TValue value )
79+ public TBuilder Set < TValue > ( Expression < Func < TObject , TValue > > property , TValue value )
8080 {
8181 _properties [ PropertyNameGetter . Get ( property ) ] = value ;
8282 return this as TBuilder ;
83+ return this as TBuilder ;
8384 }
8485
8586 /// <summary>
You can’t perform that action at this time.
0 commit comments