String Rules


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

Default

By default string values are the name of the property suffixed with an incrementing number for each generated item

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

// samples[0].FirstValue = "FirstValue1"
// samples[1].FirstValue = "FirstValue2"
// ...
// samples[4].FirstValue = "FirstValue5"

UseRange

Randomly chooses a value within the specified numeric 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:14 AM by JRoughan, version 1

Comments

No comments yet.