I have a class that conceptually looks like this:
public class Entity
{
private readonly List<double> _values = new List<double>();
...
public List<double> Values
{
get
{
return _values;
}
}
}
In a unit test, I want to use AutoFixture to provide a list of random entities:
var entities = this.fixture.CreateMany<Entity>().ToList();
However, no autogenerated values are added to the Values property of the Entity objects, as I would have expected (hoped...). I have tried to change the list of values to not being readonly and add a setter to the Values property, which solves the problem, but isn't there a better alternative to this?