Table of Contents

Class Randomizer

Namespace
NUnit.Framework.Internal
Assembly
nunit.framework.dll

Randomizer returns a set of random _values in a repeatable way, to allow re-running of tests if necessary.

This class is an internal framework class used for setting up tests. It is used to generate random test parameters, at the time of loading the tests. It also generates seeds for use at execution time, when creating a RandomGenerator for use by the test.

public class Randomizer : Random
Inheritance
Randomizer
Inherited Members

Constructors

Randomizer()

Construct a randomizer using a random seed

public Randomizer()

Randomizer(int)

Construct a randomizer using a specified seed

public Randomizer(int seed)

Parameters

seed int

Properties

InitialSeed

Initial seed used to create randomizers for this run

public static int InitialSeed { get; set; }

Property Value

int

Methods

CreateRandomizer()

Create a new Randomizer using the next seed available to ensure that each randomizer gives a unique sequence of _values.

public static Randomizer CreateRandomizer()

Returns

Randomizer

GetDoubles(double, double, int)

Return an array of random doubles with _values in a specified range.

public double[] GetDoubles(double min, double max, int count)

Parameters

min double
max double
count int

Returns

double[]

GetDoubles(int)

Return an array of random doubles between 0.0 and 1.0.

public double[] GetDoubles(int count)

Parameters

count int

Returns

double[]

GetEnums(int, Type)

Return an array of random Enums

public object[] GetEnums(int count, Type enumType)

Parameters

count int
enumType Type

Returns

object[]

GetInts(int, int, int)

Return an array of random ints with _values in a specified range.

public int[] GetInts(int min, int max, int count)

Parameters

min int
max int
count int

Returns

int[]

GetRandomizer(MemberInfo)

Get a randomizer for a particular member, returning one that has already been created if it exists. This ensures that the same _values are generated each time the tests are reloaded.

public static Randomizer GetRandomizer(MemberInfo member)

Parameters

member MemberInfo

Returns

Randomizer

GetRandomizer(ParameterInfo)

Get a randomizer for a particular parameter, returning one that has already been created if it exists. This ensures that the same _values are generated each time the tests are reloaded.

public static Randomizer GetRandomizer(ParameterInfo parameter)

Parameters

parameter ParameterInfo

Returns

Randomizer