I am trying to create a fixture using AutoFixture where one property of the object is related to another, and one of the properties is created as part of the fixture.
What I have so far is:
fixture = new Fixture().Customize(new MultipleCustomization());
Object object;
double constant;
object = fixture.Build<Object>()
.With(o => o.PropertyOne, fixture.Create<double>)
.With(o => o.PropertyTwo, constant * o.PropertyOne)
.Create());
Which doesn't work because "The name 'o' does not exist in the current context", which makes sense.
Is there any way to do this as part of the creation of the fixture?
My situation is a little more complicated because I am actually generating a list, so the code would look like:
fixture = new Fixture().Customize(new MultipleCustomization());
List<Object> objectListFixture;
double constant;
objectListFixture.AddRange(
fixture.Build<Object>()
.With(o => o.PropertyOne, fixture.Create<double>)
.With(o => o.PropertyTwo, constant * o.PropertyOne)
.CreateMany());
And I would really like to avoid a for loop if possible.
double
is created for each member of the list'? – AcrilanPropertyOne
– ArboretumPropertyOne
values are different. – AcrilanPropertyOne
first), it's working for me now. – ArboretumSelect
in the end. Thank you! – Arboretum