Sometimes it is necessary that the ObjectFiller should NOT create or fill a property or type.
For example when it gets set from the constructor or it gets filled by another property or method.
In that case you can ignore the property or type by calling
.IgnoreIt()
in the setup.In the following example we see, that the properties LastName
and Name
as well as the type DateTime
of the person will be ignored by the ObjectFiller.NET.
When the ObjectFiller.NET creates the Person
object the Name
and LastName
remaining null and the Birthday
will be the default value of DateTime!
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(x=>x.LastName, x=>x.Name).IgnoreIt()
.OnType<DateTime>().IgnoreIt();
Person filledPerson = pFiller.Create();
}
}