Search code examples
c#autofixturetest-data

Create a list of objects by an example object


I want AutoFixture to create a list of an object by using an example object.

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}

var examplePerson = new Person { Name = "Test", Age = 34 };
var persons = fixture.CreateMany<Person>();

Conventions I would like to have:

  • create string with max. length of the provided string length (4 in this example)
  • create integers where the max. amount of the computed digits equals the provided digits
  • with a decimal of 14.99 create similar decimals like 93.12
  • and so on

So I want AutoFixture to learn from my given example object.

Is this possible :)?


Solution

  • Is this possible :)?

    No, AutoFixture has no built-in AI.