Skip to content

Commit d8f9192

Browse files
Fixed a typo, added unit test.
1 parent b89dac3 commit d8f9192

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

NTestDataBuilder.Tests/BuildTests.cs

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

NTestDataBuilder/TestDataBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected virtual void AlterProxy(TObject proxy) {}
7878
public TBuilder Set<TValue>(Expression<Func<TObject, TValue>> property, TValue value)
7979
{
8080
_properties[GetPropertyName(property)] = value;
81-
return (TBuilder)this;
81+
return this as TBuilder;
8282
}
8383

8484
/// <summary>

0 commit comments

Comments
 (0)