Pick Rules


These rules can be applied to properties of any type.


class SampleData
{
    public string Value { get; set; }
}

PickFrom

Provide a set of values to be randomly chosen for all generated items.

PickFrom Parameters


var sampleData = Fabricator.Setup<SampleData>()
                           .For(x => x.Value).PickFrom("MyValue", "OtherValue", "AnotherValue")
                           .Generate();

// sampleData.Value = "MyValue" | "OtherValue" | "AnotherValue"

PickFrom Collection


var possibleValues = new List<string> { "MyValue", "OtherValue", "AnotherValue" };
var sampleData = Fabricator.Setup<SampleData>()
                           .For(x => x.Value).PickFrom(possibleValues )
                           .Generate();

// sampleData.Value = "MyValue" | "OtherValue" | "AnotherValue"

Last edited Nov 13, 2010 at 6:05 AM by JRoughan, version 1

Comments

No comments yet.