Handle IEnumerable Properties
Properties which are of type IEnumerable like lists or dictionaries can also be filled by ObjectFiller.NET like it is shown in the following example.
public class Person
{
public Dictionary<string, List<Address>>
SenselessDictionary { get; set; }
public List<IAddress> SenselessList { 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();
}
}
Updated less than a minute ago