Numeric Rules

These rules can be applied to properties of type int, float, double, or decimal.

class SampleData
{
    public int FirstValue { get; set; }
    public int SecondValue { get; set; }
}

Default

By default numeric properties are incremented by one for each generated item

var samples = Fabricator.Generate<SampleData>(5);

// samples[0].FirstValue = 1
// samples[1].FirstValue = 2
// ...
// samples[4].FirstValue = 5

UseRange

Randomly chooses a value within the specified range (inclusive).

var sampleData = Fabricator.Setup<SampleData>()
                           .For(x => x.FirstValue).UseRange(5, 10)
                           .Generate();

// sampleData.FirstValue = 5 | 6 | 7 | 8 | 9 | 10

Last edited Nov 13, 2010 at 12:11 AM by JRoughan, version 3

Comments

No comments yet.