使用AutoFixture将descendant属性设置为父ID

时间:2016-04-10 15:36:41

标签: autofixture

我的客户对象具有CustomerNote属性。当AutoFixture创建我的客户时,它还会创建一个CustomerNote。我的CustomerNote有一个CustomerId的属性(Guid)。

如果没有明确设置变量(var cId = Guid.New //然后在创建客户时传递它),可以将我的CustomerNote.CustomerId设置为' this'客户?

注意:我使用Autofixture为EF db播种

var Biller = _Fixture.Create<Biller>();
var Customer = _Fixture.Build<Customer>().With(x => x.Biller, Biller)
                                                    .With(x => x.BillerId, Biller.Id)
                                                    .Create();

0 个答案:

没有答案
相关问题