Skip to content

Commit 7b45c89

Browse files
committed
Merge remote-tracking branch 'origin/master' into release-2.0.0
Conflicts: NTestDataBuilder/TestDataBuilder.cs
2 parents 2e0c6c0 + dbbeb4e commit 7b45c89

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

NTestDataBuilder.Tests/BuildTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

NTestDataBuilder/TestDataBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)