Documentation

The PatternGenerator can be used to created strings following a certain pattern. The actual pattern documentation can be found in PatternGenerator documentation.

In the following example the Address.City will become a string, starting with exactly one upper-case char, followed by 2..8 lower-case chars.

Address.PostalCode will start with the fixed value "CA ", followed by a number starting at 10000, incremented by 1 in the next address in the persons address list.

The property `Street´will contain the text "Street ", followed by a (street) number starting at 100, incremented by 10.

public class Person
{
  public string Name { get; set; }
  public string LastName { get; set; }
  public int Age { get; set; }
  public DateTime Birthday { get; set; }
  public List<Address> Address { get; set; }
}

public class Address
{
  public string Street { get; set; }
  public string City { get; set; }
  public string PostalCode { get; set; }
}

public class HelloFiller
{
  public void FillPerson()
  {
    Filler<Person> pFiller = new Filler<Person>();

    pFiller.Setup()
      .SetupFor<Address>()
      .OnProperty(x => x.City)
      .Use(new PatternGenerator("{A}{a:2-8}"))
      .OnProperty(x => x.PostalCode)
      .Use(new PatternGenerator("CA {C:10000}"))
      .OnProperty(x => x.Street)
      .Use(new PatternGenerator("Street {C:100,10} NE"));

    Person filledPerson = pFiller.Create();
  }
}