I have the following nested classes, that are coming from XSD files generated via xsd.exe.
public class MyClass
{
public AnotherClass[] PropertyOne;
public DateTime PropertyTwo;
public bool PropertyTwoSpecified
}
public class AnotherClass
{
public DateTime AnotherPropertyOne
public bool AnotherPropertyOneSpecified
public int AnotherPropertyTwo
public bool AnotherPropertyTwoSpecified
}
Now I would like to use AutoFixture to generate instances with synthetic data.
var fixture = new Fixture();
fixture.Customize(new AutoFakeItEasyCustomization());
var myClassFake = fixture.Create<MyClass>();
I know I can use .with
to set single properties, but how can I set properties based on a specific pattern? Especially when this properties are nested in arrays?
I basically have to ensure that all properties ending with *Specified
are getting set to true
. Including the once nested into PropertyOne
Do I have to use my one reflection based method, e.g. an extension method (e.g. myClassFake.EnableAllProperties()
) or is there an AutoFixture-way to achieve my goal?
Edit
I know I can use fixture.Register<bool>(() => true);
to set all my bools to true. This solves my very specific problem, but still feels clumsy and not generally applicable. Still looking for the precise way to solve this.