In our code base, we have places where people do
Variant #1: Create and set
var item = _fixture.Create<MyType>();
item.Property1 = "foo";
others that use the build/with
Variant #2: Build/With
var item = _fixture.Build<MyType>()
.With(x => x.Property1, "foo")
.Create();
And others that use the recommended
Variant #3: Customize and Create
_fixture.Customize<MyType>(c => c
.With(x => x.Property1, "foo"));
var item = _fixture.Create<MyType>();
We want to give standardized guidelines but we can’t find anywhere a good comparison of the methods nor a list of pros and cons.
Without entering into philosophical almost religious debates, when and why should we use each variant? What are the technical pros and cons of each?