【发布时间】:2019-03-28 00:34:00
【问题描述】:
这是我正在尝试做的一个示例
var foo = CreateFoo(); // I don't have access to the internals of CreateFoo
fixture.Populate(foo); // foo should now have random property values
显然,没有Fixture.Populate 方法。但是我应该如何解决这个问题?
谢谢!
【问题讨论】:
-
您可以使用 AutoFixture 自定义,这个非常流行,当您要求 autofixture 创建一个对象时,它会使用随机值填充属性...通常 NameOfProperty 附加一个 GUID.. 使用它,只需按如下方式创建您的 IFixture: IFixture fixture = new Fixture().Customize(new AutoMoqCustomization());
标签: autofixture