New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FromFactory does not work as intended #898
Comments
I noticed that if I add |
Well, it's likely an issue with our documentation By default AutoFixture automatically populates properties with public setters, unless you disable that behavior by setting Actually, the proper AutoFixture API usage depends on the scenario. The most "idiomatic" usage in the scenario above would be the following: f.Customize<TestClass>(c => c
.FromFactory(() => new TestClass())
.With(x => x.Property, "foobar")); or even the simplified one as AutoFixture will automatically pick up that constructor: f.Customize<TestClass>(c => c
.With(x => x.Property, "foobar")); Alternatively, you can simply disable the automatic properties fill-up if you need that: f.Customize<TestClass>(c => c
.FromFactory(() => new TestClass { Property = "foobar" })
.OmitAutoProperties()); However, in this case, probably, the f.Register(() => new TestClass { Property = "foobar" }); It might be confusing at the beginning to understand which exact API suits better, but later it should go easier 😉All this API gives the flexibility and in different scenarios the different options look better. Let me know if you still have some questions to clarify and I'll gladly help you. P.S. The following links might also help:
P.P.S. The reason why |
Thank you so much for this incredible answer! You're amazing :) |
Hi,
This test fails using 4.0.0-rc1 on .NET Core 2
I think this is either misleading (or poorly documented)
or broken.EDIT : It's not broken, see comments below.
The text was updated successfully, but these errors were encountered: