Skip to content

Commit c788cb3

Browse files
committed
Making it explicit that the AutoFixtureFactory does not use values from the builder
1 parent d95116c commit c788cb3

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

TestStack.Dossier.Tests/Factories/AutoFixtureFactoryTests.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,26 @@ public void GivenAutoFixtureFactory_WhenBuilding_ThenOnlyConstructorAndPublicPro
1313
{
1414
MixedAccessibilityDto dto = Builder<MixedAccessibilityDto>.CreateNew(new AutoFixtureFactory());
1515

16-
// ctor properties
1716
dto.SetByCtorWithPrivateSetter.ShouldNotBe(null);
1817
dto.SetByCtorWithPublicSetter.ShouldNotBe(null);
19-
20-
// public properties
18+
dto.NotSetByCtorWithPrivateSetter.ShouldBe(null);
2119
dto.NotSetByCtorWithPublicSetter.ShouldNotBe(null);
20+
}
2221

23-
// private properties
24-
dto.NotSetByCtorWithPrivateSetter.ShouldBe(null);
22+
[Fact]
23+
public void GivenAutoFixtureFactoryAgainstBuilderWithModifications_WhenBuilding_ThenNoCustomisationsAreUsed()
24+
{
25+
MixedAccessibilityDto dto = Builder<MixedAccessibilityDto>
26+
.CreateNew(new AutoFixtureFactory())
27+
.Set(x => x.SetByCtorWithPrivateSetter, "1")
28+
.Set(x => x.SetByCtorWithPublicSetter, "2")
29+
.Set(x => x.NotSetByCtorWithPrivateSetter, "3")
30+
.Set(x => x.NotSetByCtorWithPublicSetter, "4");
31+
32+
dto.SetByCtorWithPrivateSetter.ShouldNotBe("1");
33+
dto.SetByCtorWithPublicSetter.ShouldNotBe("2");
34+
dto.NotSetByCtorWithPrivateSetter.ShouldNotBe("3");
35+
dto.NotSetByCtorWithPublicSetter.ShouldNotBe("4");
2536
}
2637
}
2738
}

TestStack.Dossier/Factories/AutoFixtureFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace TestStack.Dossier.Factories
44
{
55
/// <summary>
6-
/// Creates an instance of an object with AutoFixture.
6+
/// Creates an instance of an object with AutoFixture - any values set in your builder will NOT be used to construct the object.
77
/// </summary>
88
public class AutoFixtureFactory : IFactory
99
{

0 commit comments

Comments
 (0)