Hierarchy Rules


These rules can be applied between a property of an owned type and a property of the owner.

class Parent
{
    public Guid Id { get; private set; }
    public Child MyChild { get; set; }
}

class Child
{
    public Guid ParentId { get; set; }
}

Link

Set a property of an owned type to have the same value as a property of the owner.

var sampleData = Fabricator.Setup<SampleData>()
                           .ForChild(x => x.MyChild).Link(c => c.ParentId).To(x => x.Id)
                           .Generate();

// sampleData.ParentId= sampleData.MyChild.ParentId

Notes
  • If a parent=>child link results in recursion an unspecified number of items will be populated before Fabricator will skip population to prevent a stack overflow

Last edited Nov 21, 2010 at 5:27 AM by JRoughan, version 2

Comments

No comments yet.