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 string Phone { 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()
      .OnProperty(p => p.Phone)
      	.Use("{N:3}-{N:3}-{N:4}")
      .SetupFor<Address>()
      	.OnProperty(a => a.City)
      		.Use(new PatternGenerator("{A}{a:2-8}"))
	      .OnProperty(a => a.PostalCode)
  	    	.Use(new PatternGenerator("CA {C:10000}"))
    	  .OnProperty(a => a.Street)
      		.Use(new PatternGenerator("Street {C:100,10} NE"));

    Person filledPerson = pFiller.Create();
  }
}