Setup for Properties

The setup for a property works very equal to the setup of a type. After we called .Setup() on the ObjectFiller.NET we can configure a property of the target object by calling .OnProperty(x=>x.Property).
In the following example we setup the property Name of a Person to have the value "John" and fill the property LastName with some random real lastname. With .Use(new RealNames(NameStyle.LastName); we use the RealNamePlugin. The RealNamePlugin is a plugin which comes with the ObjectFiller.NET assembly along. You can use the plugins for types as well as for properties. It is also really easy to write a plugin by yourself. You can read more about it in the chapter "Extend ObjectFiller.NET".

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

public class HelloFiller
{
  public void FillPerson()
  {
    Filler<Person> pFiller = new Filler<Person>();
    pFiller.Setup()
      .OnProperty(p => p.Name)
      	.Use("John")
      .OnProperty(p => p.LastName)
      	.Use(new RealNames(NameStyle.LastName));

    Person filledPerson = pFiller.Create();
  }
}