Documentation

In the following example the class Person has a property Address of the interface type IAddress!
To fill properties which are type of an interface it is necessary to register the implementation type of the interface in the ObjectFiller.NET setup. This can be done by calling the method .OnType<TInterface>().CreateInstanceOf<TImplemenation>().

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

public class Address : IAddress
{
  public string Street { get; set; }
  public string City { get; set; }
}

public interface IAddress { }

public class HelloFiller
{
  public void FillPerson()
  {
    Filler<Person> pFiller = new Filler<Person>();
    pFiller.Setup()
      .OnType<IAddress>().CreateInstanceOf<Address>();

    Person filledPerson = pFiller.Create();
  }
}