Open nailThrasher opened 2 years ago
Hey @nailThrasher
Have you tried the override capabilities of AutoBogus? You can define an override for a int
and ensure only positive values are generated. You can read about overrides here:
Hope that helps.
Nick.
Another option is RuleForType
?
e.g.
var faker = new AutoFaker<Test>();
faker.RuleForType(typeof(int), f => f.Random.Int(0));
faker.RuleForType(typeof(int?), f => f.Random.Int(0));
Or use it with a own class:
public sealed class MyFaker<T> : AutoFaker<T> where T : class
{
public MyFaker()
{
RuleForType(typeof(int), f => f.Random.Int(0));
RuleForType(typeof(int?), f => f.Random.Int(0));
}
}
// Usage
var faker = new MyFaker<Test>();
Hello! Is there a way to do that (maybe through range set)? If yes, please tell me how, because negative ints are not suitable for my need, and i have a lot of int properties and writing RuleFor each of them will be quite tedious.