-
Notifications
You must be signed in to change notification settings - Fork 337
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
Callback after an object is created #988
Comments
Hi @Kralizek, thanks for raising this issue. Unfortunately, currently API doesn't allow you to register callback that is executed after the properties are assigned. It's unlikely that you could somehow work around that using the I'm registering that as a potential feature, as current API features are not enough for scenario like this. I do understand that we should not cover all the potential usages, however current scenario looks fundamental. |
I believe this is one of the most useful functionality that are currently missing in an otherwise awesome pkg! |
I got a class with some properties and a dictionary that contains the value of each property. I'm trying to use a customization to get that nasty dictionary populated with the right values, but the "Do" method gets invoked before the properties are valued. So I got a dictionary with "items" but the items have no value :(
The problem I am experiencing is that "Do" is executed during the object creation, when the properties are not yet populated.
Ideally I would love to have a method that gets executed after the object is created. Something like
OnCreate<T>(Action<T>)
.This is a sample of class I want get from AutoFixture.
Here is my attempt to solve the issue with
Do<T>(Action<T>)
And here is a simple unit test that shows my intended result
where
ContactAutoData
is a specialization ofAutoDataAttribute
of AutoFixture.NUnit3 fed with the fixture customized above.The text was updated successfully, but these errors were encountered: