【问题标题】:Create a list of objects by an example object通过示例对象创建对象列表
【发布时间】:2014-05-21 16:00:50
【问题描述】:

我希望 AutoFixture 使用示例对象创建对象列表。

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}

var examplePerson = new Person { Name = "Test", Age = 34 };
var persons = fixture.CreateMany<Person>();

我想要的约定:

  • 创建最大字符串。提供的字符串长度的长度(本例中为 4)
  • 在最大值处创建整数。计算的位数等于提供的位数
  • 使用小数点 14.99 创建类似的小数点,如 93.12
  • 等等

所以我希望 AutoFixture 从我给定的示例对象中学习。

这可能吗:)?

【问题讨论】:

  • 您所描述的可能是可能的,但它可能会导致难以编写的单元测试。请先考虑3rd paragraph from here

标签: c# autofixture test-data


【解决方案1】:

这可能吗:)?

不,AutoFixture 没有内置 AI。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    • 2015-03-24
    相关资源
    最近更新 更多