You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 Customize<> API.
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 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: