Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.36 KB

File metadata and controls

45 lines (35 loc) · 1.36 KB

see also:


This project provides tools for populating class instance properties for testing purposes, usually with random values:

using SparkyTestHelpers.Population;
    var populater = new Populater();

    var foo = new Foo();
    populater.PopulateWithRandomValues(foo);

    var foo2 = populater.CreateRandom<Foo>();

There's also a GetRandom static method that uses Populater "behind the scenes":

using SparkyTestHelpers.Population;
    var foo = GetRandom.InstanceOf<Foo>();

The project also has a SequentialValueProvider and associated methods that populates class properties with predictable/repeatable values. I hope to use it in the future for "snapshot testing":

using SparkyTestHelpers.Population;
    var populater = new Populater();

    var foo = new Foo();
    populater.Populate(foo, new SequentialValueProvider()); 

    // (SequentialValueProvider is the default provider for the "Populate" method:
    var foo2 = new Foo();
    populater.Populate(foo);

    var foo3 = populater.CreateAndPopulate<Foo>();