PeanutButter
Loading...
Searching...
No Matches
PeanutButter.RandomGenerators.RandomValueGen Class Reference

Class which provides a number of static methods to produce random values. Suggestion: make use of "using static" to bring these methods into your class as if they were local members, ie: using static PeanutButter.RandomGenerators.RandomValueGen;. More...

Classes

class  DefaultRanges
 Exposes the default range values used within RandomValueGen when the ranges are omitted by calling code. More...

Static Public Member Functions

static T GetRandom< T > ()
 Gets a random value of the specified type by attempting to find the correct random generator method and invoking it. Works on primitives (eg int, string), enums and complex objects. When invoked on a complex object, will attempt to fine (or, if necessary, create) a GenericBuilder to produce the result.
static IDictionary< TKey, TValue > GetRandomDictionary< TKey, TValue > ()
 Generates a random dictionary of the provided key / value types with at least one item in it.
static IDictionary< TKey, TValue > GetRandomDictionary< TKey, TValue > (int minItems)
 Generates a random dictionary of the provided key / value types with at least {minItems} in it.
static IDictionary< TKey, TValue > GetRandomDictionary< TKey, TValue > (int minItems, int maxItems)
 Generates a random dictionary of the provided key / value types with at least {minItems} and at most {maxItems} in it.
static NameValueCollection GetRandomNameValueCollection ()
 Generates a random NameValueCollection with at least one item in it.
static NameValueCollection GetRandomNameValueCollection (int minItems)
 Generates a random NameValueCollection with at least {minItems} in it.
static NameValueCollection GetRandomNameValueCollection (int minItems, int maxItems)
 Generates a random NameValueCollection with at least {minItems} and at most {maxItems} in it.
static void InstallRandomGenerator< T > (Func< T > generator)
 Add a special case for generating random values, eg for types which have no parameterless constructor, but, eg, may have a .Parse method NB: this method is NOT thread-safe when used concurrently with GetRandom<T>()
static Type GetRandomType ()
 Returns a random loaded type in the current app domain.
static object GetRandom (Type type)
 Gets a random value of the specified type by attempting to find the correct random generator method and invoking it. Works on primitives (eg int, string), enums and complex objects. When invoked on a complex object, will attempt to fine (or, if necessary, create) a GenericBuilder to produce the result.
static int GetRandomInt ()
 Produces a random integer between 0 and 10 inclusive.
static int GetRandomInt (int minValue)
 Produces an integer between the provided value and that value + 10, inclusive.
static int GetRandomInt (int minValue, int maxValue)
 Returns a random integer within the specified range.
static int GetRandomIntKey ()
 Returns a random integer from 1 to 1000, as might be seen on an integer id field in a database.
static int GetRandomIntKey (int maxValue)
 Returns a random integer from 1 to {maxValue}, as might be seen on an integer id field in a database.
static bool GetRandomBoolean ()
 Returns a random boolean value.
static string GetRandomMIMEType ()
 Gets a pseudo-random mimetype (picks from a short list of known mime types)
static string GetRandomMimeType ()
 Gets a pseudo-random mimetype (picks from a short list of known mime types)
static long GetRandomLong ()
 Produces a random long between 0 and 1000, inclusive.
static long GetRandomLong (long minValue)
 Returns a random long between the provided min value and that value + 1000, inclusive.
static long GetRandomLong (long minValue, long maxValue)
 Returns a random long within the specified range.
static string GetRandomString (int minLength=DefaultRanges.MINLENGTH_STRING, int? maxLength=null, string charSet=null)
 Gets a random string.
static DateTime GetRandomDate (DateTime? minDate, DateTime? maxDate, bool dateOnly, DateTime? minTime, DateTime? maxTime)
 Gets a random Local DateTime value, by default within SQL-safe range.
static DateTime GetRandomDate ()
 Returns a local random datetime.
static DateTime GetRandomDate (DateTimeKind kind)
 Returns a random date-time with the required kind.
static DateTime GetRandomDate (DateTimeKind kind, DateTime? minDate, DateTime? maxDate, bool dateOnly, DateTime? minTime, DateTime? maxTime)
 Gets a random DateTime value of the specified kind, by default within SQL-safe range.
static DateTime GetRandomDate (DateTime? minDate=null, DateTime? maxDate=null, bool dateOnly=false, TimeSpan? minTime=null, TimeSpan? maxTime=null)
 Gets a random DateTime value of the specified kind, by default within SQL-safe range.
static DateTime GetRandomDate (DateTimeKind kind, DateTime? minDate, DateTime? maxDate=null, bool dateOnly=false, TimeSpan? minTime=null, TimeSpan? maxTime=null)
 Gets a random DateTime value of the specified kind, by default within SQL-safe range.
static DateTimeOffset GetRandomDateTimeOffset (DateTimeOffset? minDate=null, DateTimeOffset? maxDate=null, TimeSpan? minTime=null, TimeSpan? maxTime=null, bool dateOnly=false)
 Like GetRandomDate, but for DateTimeOffset values.
static DateTime GetRandomUtcDate (DateTime? minDate, DateTime? maxDate, bool dateOnly, DateTime? minTime, DateTime? maxTime)
 Returns a random UTC date within the specified range.
static DateTime GetRandomUtcDate (DateTime? minDate=null, DateTime? maxDate=null, bool dateOnly=false, TimeSpan? minTime=null, TimeSpan? maxTime=null)
 Returns a random UTC date within the specified range.
static DateRange GetRandomDateRange (DateTime? minDate=null, DateTime? maxDate=null, bool dateOnly=false, DateTime? minTime=null, DateTime? maxTime=null)
 Gets a random Local DateTime range, by default within SQL-safe range.
static DateRange GetRandomUtcDateRange (DateTime? minDate=null, DateTime? maxDate=null, bool dateOnly=false, DateTime? minTime=null, DateTime? maxTime=null)
 Gets a random Local DateTime range, by default within SQL-safe range.
static TimeSpan GetRandomTimeSpan (double min, double max=DefaultRanges.MAX_INT_VALUE, TimeSpanContexts context=TimeSpanContexts.Minutes)
 Gets a random timespan.
static TimeSpan GetRandomTimeSpan (TimeSpan min, TimeSpan? max=null)
 Returns a TimeSpan between min and max.
static TimeSpan GetRandomTimeSpan ()
 Returns a random TimeSpan between TimeSpan.Z.
static DateRange GetRandomDateRange (DateTimeKind kind, DateTime? minDate=null, DateTime? maxDate=null, bool dateOnly=false, DateTime? minTime=null, DateTime? maxTime=null)
 Gets a random DateTime range of the specified kind, by default within SQL-safe range.
static double GetRandomDouble ()
 Produces a random double value between 0 and 10 inclusive.
static double GetRandomDouble (double minValue)
 Produces a random double value between the provides double value and that value + 10, inclusive.
static double GetRandomDouble (double min, double max)
 Gets a random double value within the specified range.
static decimal GetRandomDecimal (double min, double max)
 Gets a random decimal value within the specified range.
static decimal GetRandomDecimal (long min, long max)
 Gets a random decimal value within the specified range.
static decimal GetRandomDecimal (decimal min, decimal max)
 Gets a random decimal value within the specified range.
static decimal GetRandomDecimal ()
 Produces a random decimal between 0 and 10 inclusive.
static decimal GetRandomDecimal (decimal minValue)
 Produces a random decimal between the provided minValue and that value + 10, inclusive.
static decimal GetRandomMoney (decimal min, decimal max)
 Gets a random money value (decimal with max 2 places) within the specified range.
static decimal GetRandomMoney ()
 Produces a money value (decimal with max 2 places) between 10 and 100 inclusive.
static decimal GetRandomMoney (decimal minValue)
 Produces a random decimal between the provided minValue and that value + 10, inclusive.
static decimal GetRandomTaxRate (decimal min, decimal max)
 Gets a random tax rate value (decimal with max 2 places) within the specified range.
static decimal GetRandomTaxRate ()
 Produces a tax rate value (decimal with max 2 places) between 3 and 20 inclusive.
static decimal GetRandomTaxRate (decimal minValue)
 Produces a tax rate value (decimal with max 2 places) between of the provided minimum value up to that value.
static decimal GetRandomInterestRate (decimal min, decimal max)
 Gets a random interest rate value (decimal with max 2 places) within the specified range.
static decimal GetRandomInterestRate ()
 Produces a interest rate value (decimal with max 2 places) between 3 and 20 inclusive.
static decimal GetRandomInterestRate (decimal minValue)
 Produces a interest rate value (decimal with max 2 places) between of the provided minimum value up to that value.
static decimal GetRandomDecimal (long minValue)
 Produces a random decimal between the provided minValue and that value + 10, inclusive.
static decimal GetRandomDecimal (double minValue)
 Produces a random decimal between the provided minValue and that value + 10, inclusive.
static float GetRandomFloat ()
 Produces a random float between 0 and 10 inclusive.
static float GetRandomFloat (float minValue)
 Produces a random float between the provided minValue and that value + 10, inclusive.
static float GetRandomFloat (float min, float max)
 Gets a random float value within the specified range.
static TimeSpan GetRandomTimeOfDay ()
 Produces a random time of day.
static TimeSpan GetRandomTimeOfDay (TimeSpan min)
 Produces a random time of day from the provided minimum, inclusive.
static TimeSpan GetRandomTimeOfDay (TimeSpan min, TimeSpan max)
 Returns a random time of day.
static byte[] GetRandomBytes ()
 Produces an array of random bytes between 0 and 1024 in length, inclusive.
static byte[] GetRandomBytes (int minLength)
 Produces some random bytes, of at least minLength in size, up to that length + 1024, inclusive.
static byte[] GetRandomBytes (int minLength, int maxLength)
 Gets a randomly-sized, randomly-filled byte array.
static string GetRandomEmail ()
 Gets a random email-like string. Note that this is only email-like in that it conforms to the structure: {random-string}random-string}.com.
static string GetRandomEmail (string firstName)
 Gets a random email-like string. Note that this is only email-like in that it conforms to the structure: {random-string}random-string}.com

Parameters
firstNameUse a first-name to guide the process

static string GetRandomEmail (string firstName, string lastName)
 Gets a random email-like string. Note that this is only email-like in that it conforms to the structure: {random-string}random-string}.com

Parameters
firstNameUse a first-name to guide the process
lastNameUse a last-name to guide the process

static string GetRandomDomain ()
 Returns a random domain generated from a fairly common internet company name and one of the known TLDs at time of generation.
static string GetRandomUserName ()
 Produces a random username:
static string GetRandomUserName (string firstName)
 Produces a random username:
static string GetRandomUserName (string firstName, string lastName)
 Produces a random username:
static string GetRandomCityName ()
 Generates a city name.
static string GetRandomCountry ()
 Returns a random country.
static string GetRandomCountryCode ()
 Returns a random country code.
static string GetRandomStreetAddress ()
 Generates a street address.
static string GetRandomStreetName ()
 Generates a street name.
static string GetRandomStreetNumber ()
 Generates a street number (eg 12 or 134a)
static string GetRandomStreetAddress (string streetName)
 Generates a street address, given a street name.
static string GetRandomStreetAddress (string streetNumber, string streetName)
 Generates a street address, given a street number and / or name (null values are discarded & random values will be generated)
static string GetRandomPostalCode ()
 Generates a random postal code.
static string GetRandomAddress ()
 Generates a random multi-line address.
static string GetRandomFirstName ()
 Returns a random first name, sourced from unique top names:
static string GetRandomPlaceName ()
 Generates a random fantasy place name.
static string GetRandomLastName ()
 Returns a random last name, source from unique top names:
static string GetRandomTopLevelDomainName ()
 Returns a random.
static string GetRandomName ()
 Returns a random name of the format {FirstName} {LastName}.
static string GetRandomFileName ()
 Gets a random filename. Does not use the OS-level temporary filename functions.
static string GetRandomFileExtension ()
 Returns a random valid file extension.
static string GetRandomWindowsPath ()
 Gets a random path which resembles a Windows path, including a leading drive.
static string GetRandomWords ()
 Produces a collection of words between 10 and 50 words in length, inclusive.
static string GetRandomWords (int minWords)
 Produces a collection of words with count of at least minWords up to and including minWords + 50.
static string GetRandomWords (int minWords, int maxWords)
 Gets some random pseudo-words. Note that they (probably) won't be readable words – just a collection of strings with whitespace in between. Think of this as something like Lorei Ipsum, except with zero meaning.
static string GetRandomHttpUrl ()
 Generates a random string which looks a lot like an http url, to the domain only (no path or parameters)
static string GetRandomHttpMethod ()
 Returns a random http verb, ie one of.
static string GetRandomCommonHttpMethod ()
 Returns a "more common" http method:
static string GetRandomHttpUrlWithPath ()
 Produces a string which looks just like an http url with a path.
static string GetRandomHttpUrlWithPathAndParameters ()
 Produces a string that looks like an http url with path and parameters.
static string GetRandomHttpPathAndParameters ()
 Produces just the path and query string for an http request.
static string GetRandomHttpUrlWithParameters ()
 Generates a random HTTP url with some query parameters.
static string GetRandomHttpsUrl ()
 Generates a random string which looks a lot like an https url, to the domain only (no path or parameters)
static string GetRandomHttpsUrlWithPath ()
 Produces a string which looks just like an https url with a path.
static string GetRandomHttpsUrlWithPathAndParameters ()
 Produces a string that looks like an https url with path and parameters.
static string GetRandomHttpsUrlWithParameters ()
 Generates a random https url with some query parameters.
static string GetRandomPath ()
 Generates a random string which looks like a relative path on the internet or any reasonable filesystem.
static string GetRandomAbsolutePath ()
 Returns an absolute random path (ie, always starts with /)
static string GetRandomUrlQuery ()
 Generates a random query string for an url.
static string GetRandomUrlParameters ()
 Generates a string of random url parameters.
static string GetRandomAlphaNumericString (int minLength=DefaultRanges.MINLENGTH_STRING, int? maxLength=null)
 Gets a random string made up only of alphanumeric characters.
static string GetRandomNonAlphaNumericString (int minChars=0, int maxChars=10)
 Gets a random string made of non-alpha-numeric (but printable) chars.
static string GetRandomAlphaString (int minLength=DefaultRanges.MINLENGTH_STRING, int? maxLength=null)
 Gets a random string made up only of alphabetic characters.
static string GetRandomNumericString (int minLength=DefaultRanges.MINLENGTH_STRING, int? maxLength=null)
 Gets a random string made up only of numeric characters.
static T GetRandomEnum< T > ()
 Gets a random enum value from the specified enum type.
static T GetRandomEnum< T > (params T[] excludingValues)
 Gets a random enum value from the specified enum type. You may optionally specify enum values that you don't want in the output.
static T GetRandomEnum< T > (Func< T, bool > validator)
 Gets a random enum value from the specified enum type with validation for a required value.
static string GetRandomVersionString (int partCount=3)
 Gets a random version-like string (eg 1.2.3)
static Version GetRandomVersion ()
 Gets a random System.Version instance.
static string CreateRandomFolderIn (string path)
 Creates a randomly-named folder within another existing folder and returns the name of that folder.
static IEnumerable< string > CreateRandomFoldersIn (string path, int depth=2)
 Creates some randomly-named folder within another existing folder and returns the names of those folders.
static string CreateRandomFileIn (string path)
 Creates a randomly-named file within the provided folder path and returns its name.
static string CreateRandomTextFileIn (string path)
 Creates a randomly-named file within the provided folder path and populates it with some random text data; returns the name of the file.
static IEnumerable< string > CreateRandomFileTreeIn (string path)
 Creates a full random file tree (folders and some files, to a depth of 2) under a given path. Useful when you need to test utilities which trawl the filesystem.
static IEnumerable< string > CreateRandomFileTreeIn (string path, int depth)
 Creates a full random file tree (folders and some files) under a given path. Useful when you need to test utilities which trawl the filesystem.
static string GetRandomLanguageCode ()
 Provides a random language code.
static string GetRandomLanguageName ()
 Provides a random language name.

Detailed Description

Class which provides a number of static methods to produce random values. Suggestion: make use of "using static" to bring these methods into your class as if they were local members, ie: using static PeanutButter.RandomGenerators.RandomValueGen;.

Member Function Documentation

◆ CreateRandomFileIn()

string PeanutButter.RandomGenerators.RandomValueGen.CreateRandomFileIn ( string path)
static

Creates a randomly-named file within the provided folder path and returns its name.

Parameters
pathFolder within which to create the file
Returns
Name of the file (name only, not full path)

◆ CreateRandomFileTreeIn() [1/2]

IEnumerable< string > PeanutButter.RandomGenerators.RandomValueGen.CreateRandomFileTreeIn ( string path)
static

Creates a full random file tree (folders and some files, to a depth of 2) under a given path. Useful when you need to test utilities which trawl the filesystem.

Parameters
pathFolder in which to create the tree
Returns
A collection of relative paths to the files within the created tree

◆ CreateRandomFileTreeIn() [2/2]

IEnumerable< string > PeanutButter.RandomGenerators.RandomValueGen.CreateRandomFileTreeIn ( string path,
int depth )
static

Creates a full random file tree (folders and some files) under a given path. Useful when you need to test utilities which trawl the filesystem.

Parameters
pathFolder in which to create the tree
depthHow deep to make the folder structure
Returns
A collection of relative paths to the files within the created tree

◆ CreateRandomFolderIn()

string PeanutButter.RandomGenerators.RandomValueGen.CreateRandomFolderIn ( string path)
static

Creates a randomly-named folder within another existing folder and returns the name of that folder.

Parameters
pathBase path within which to create the new folder
Returns
Just the name of the created folder (not the full path)

◆ CreateRandomFoldersIn()

IEnumerable< string > PeanutButter.RandomGenerators.RandomValueGen.CreateRandomFoldersIn ( string path,
int depth = 2 )
static

Creates some randomly-named folder within another existing folder and returns the names of those folders.

Parameters
pathBase path within which to create the new folder
depthHow deep to go when creating the tree
Returns
Just the names of the created folders (not the full paths)

◆ CreateRandomTextFileIn()

string PeanutButter.RandomGenerators.RandomValueGen.CreateRandomTextFileIn ( string path)
static

Creates a randomly-named file within the provided folder path and populates it with some random text data; returns the name of the file.

Parameters
pathFolder within which to create the file
Returns
Name of the file (name only, not full path)

◆ GetRandom()

object PeanutButter.RandomGenerators.RandomValueGen.GetRandom ( Type type)
static

Gets a random value of the specified type by attempting to find the correct random generator method and invoking it. Works on primitives (eg int, string), enums and complex objects. When invoked on a complex object, will attempt to fine (or, if necessary, create) a GenericBuilder to produce the result.

Parameters
typeType to generate a random value of
Returns
New instance of the specified type. Should be different every time, when possible.

◆ GetRandom< T >()

Gets a random value of the specified type by attempting to find the correct random generator method and invoking it. Works on primitives (eg int, string), enums and complex objects. When invoked on a complex object, will attempt to fine (or, if necessary, create) a GenericBuilder to produce the result.

Template Parameters
TType to generate a random value of
Returns
New instance of the specified type. Should be different every time, when possible.

◆ GetRandomAbsolutePath()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomAbsolutePath ( )
static

Returns an absolute random path (ie, always starts with /)

Returns

◆ GetRandomAddress()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomAddress ( )
static

Generates a random multi-line address.

Returns

◆ GetRandomAlphaNumericString()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomAlphaNumericString ( int minLength = DefaultRanges::MINLENGTH_STRING,
int? maxLength = null )
static

Gets a random string made up only of alphanumeric characters.

Parameters
minLengthMinimum length required
maxLengthMaximum length required
Returns
Random string made up of only alphanumeric characters

◆ GetRandomAlphaString()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomAlphaString ( int minLength = DefaultRanges::MINLENGTH_STRING,
int? maxLength = null )
static

Gets a random string made up only of alphabetic characters.

Parameters
minLengthMinimum length required
maxLengthMaximum length required
Returns
Random string made up of only alphabetic characters

◆ GetRandomBoolean()

bool PeanutButter.RandomGenerators.RandomValueGen.GetRandomBoolean ( )
static

Returns a random boolean value.

Returns
True or False

◆ GetRandomBytes() [1/3]

byte[] PeanutButter.RandomGenerators.RandomValueGen.GetRandomBytes ( )
static

Produces an array of random bytes between 0 and 1024 in length, inclusive.

Returns

◆ GetRandomBytes() [2/3]

byte[] PeanutButter.RandomGenerators.RandomValueGen.GetRandomBytes ( int minLength)
static

Produces some random bytes, of at least minLength in size, up to that length + 1024, inclusive.

Parameters
minLength
Returns

◆ GetRandomBytes() [3/3]

byte[] PeanutButter.RandomGenerators.RandomValueGen.GetRandomBytes ( int minLength,
int maxLength )
static

Gets a randomly-sized, randomly-filled byte array.

Parameters
minLengthMinimum size of the result
maxLengthMaximum size of the result
Returns
Randomly-filled byte array

◆ GetRandomCityName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomCityName ( )
static

Generates a city name.

Returns

◆ GetRandomCommonHttpMethod()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomCommonHttpMethod ( )
static

Returns a "more common" http method:

  • 60% GET
  • 20% POST
  • 10% PUT
  • 10% DELETE
Returns

◆ GetRandomCountry()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomCountry ( )
static

Returns a random country.

Returns

◆ GetRandomCountryCode()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomCountryCode ( )
static

Returns a random country code.

Returns

◆ GetRandomDate() [1/6]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomDate ( )
static

Returns a local random datetime.

Returns

◆ GetRandomDate() [2/6]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomDate ( DateTime? minDate,
DateTime? maxDate,
bool dateOnly,
DateTime? minTime,
DateTime? maxTime )
static

Gets a random Local DateTime value, by default within SQL-safe range.

Parameters
minDateMinimum date to consider
maxDateMaximum date to consider
dateOnlyFlag to determine if times should be truncated
minTimeMinimum time to consider (default all)
maxTimeMaximum time to consider (default all)
Returns
Random Local DateTime within the specified range

◆ GetRandomDate() [3/6]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomDate ( DateTime? minDate = null,
DateTime? maxDate = null,
bool dateOnly = false,
TimeSpan? minTime = null,
TimeSpan? maxTime = null )
static

Gets a random DateTime value of the specified kind, by default within SQL-safe range.

Parameters
minDateMinimum date to consider
maxDateMaximum date to consider
dateOnlyFlag to determine if times should be truncated
minTimeMinimum time to consider (default all)
maxTimeMaximum time to consider (default all)
Returns
Random DateTime value of the specified kind, within the specified range

◆ GetRandomDate() [4/6]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomDate ( DateTimeKind kind)
static

Returns a random date-time with the required kind.

Parameters
kind
Returns

◆ GetRandomDate() [5/6]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomDate ( DateTimeKind kind,
DateTime? minDate,
DateTime? maxDate,
bool dateOnly,
DateTime? minTime,
DateTime? maxTime )
static

Gets a random DateTime value of the specified kind, by default within SQL-safe range.

Parameters
kindDateTimeKind required for this value
minDateMinimum date to consider
maxDateMaximum date to consider
dateOnlyFlag to determine if times should be truncated
minTimeMinimum time to consider (default all)
maxTimeMaximum time to consider (default all)
Returns
Random DateTime value of the specified kind, within the specified range

◆ GetRandomDate() [6/6]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomDate ( DateTimeKind kind,
DateTime? minDate,
DateTime? maxDate = null,
bool dateOnly = false,
TimeSpan? minTime = null,
TimeSpan? maxTime = null )
static

Gets a random DateTime value of the specified kind, by default within SQL-safe range.

Parameters
kindDateTimeKind required for this value
minDateMinimum date to consider
maxDateMaximum date to consider
dateOnlyFlag to determine if times should be truncated
minTimeMinimum time to consider (default all)
maxTimeMaximum time to consider (default all)
Returns
Random DateTime value of the specified kind, within the specified range

◆ GetRandomDateRange() [1/2]

DateRange PeanutButter.RandomGenerators.RandomValueGen.GetRandomDateRange ( DateTime? minDate = null,
DateTime? maxDate = null,
bool dateOnly = false,
DateTime? minTime = null,
DateTime? maxTime = null )
static

Gets a random Local DateTime range, by default within SQL-safe range.

Parameters
minDateMinimum date to consider
maxDateMaximum date to consider
dateOnlyFlag to determine if times should be truncated
minTimeMinimum time to consider (default all)
maxTimeMaximum time to consider (default all)
Returns
Random Local DateTime value

◆ GetRandomDateRange() [2/2]

DateRange PeanutButter.RandomGenerators.RandomValueGen.GetRandomDateRange ( DateTimeKind kind,
DateTime? minDate = null,
DateTime? maxDate = null,
bool dateOnly = false,
DateTime? minTime = null,
DateTime? maxTime = null )
static

Gets a random DateTime range of the specified kind, by default within SQL-safe range.

Parameters
kindDateTimeKind required for this value
minDateMinimum date to consider
maxDateMaximum date to consider
dateOnlyFlag to determine if times should be truncated
minTimeMinimum time to consider (default all)
maxTimeMaximum time to consider (default all)
Returns
DateRange object with From and To within the specified range

◆ GetRandomDateTimeOffset()

DateTimeOffset PeanutButter.RandomGenerators.RandomValueGen.GetRandomDateTimeOffset ( DateTimeOffset? minDate = null,
DateTimeOffset? maxDate = null,
TimeSpan? minTime = null,
TimeSpan? maxTime = null,
bool dateOnly = false )
static

Like GetRandomDate, but for DateTimeOffset values.

Parameters
minDate
maxDate
minTime
maxTime
dateOnly
Returns

◆ GetRandomDecimal() [1/7]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomDecimal ( )
static

Produces a random decimal between 0 and 10 inclusive.

Returns

◆ GetRandomDecimal() [2/7]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomDecimal ( decimal min,
decimal max )
static

Gets a random decimal value within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Decimal value within the specified range

◆ GetRandomDecimal() [3/7]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomDecimal ( decimal minValue)
static

Produces a random decimal between the provided minValue and that value + 10, inclusive.

Parameters
minValue
Returns

◆ GetRandomDecimal() [4/7]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomDecimal ( double min,
double max )
static

Gets a random decimal value within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Decimal value within the specified range

◆ GetRandomDecimal() [5/7]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomDecimal ( double minValue)
static

Produces a random decimal between the provided minValue and that value + 10, inclusive.

Parameters
minValue
Returns

◆ GetRandomDecimal() [6/7]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomDecimal ( long min,
long max )
static

Gets a random decimal value within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Decimal value within the specified range

◆ GetRandomDecimal() [7/7]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomDecimal ( long minValue)
static

Produces a random decimal between the provided minValue and that value + 10, inclusive.

Parameters
minValue
Returns

◆ GetRandomDictionary< TKey, TValue >() [1/3]

IDictionary< TKey, TValue > PeanutButter.RandomGenerators.RandomValueGen.GetRandomDictionary< TKey, TValue > ( )
static

Generates a random dictionary of the provided key / value types with at least one item in it.

Template Parameters
TKey
TValue
Returns

◆ GetRandomDictionary< TKey, TValue >() [2/3]

IDictionary< TKey, TValue > PeanutButter.RandomGenerators.RandomValueGen.GetRandomDictionary< TKey, TValue > ( int minItems)
static

Generates a random dictionary of the provided key / value types with at least {minItems} in it.

Template Parameters
TKey
TValue
Returns

◆ GetRandomDictionary< TKey, TValue >() [3/3]

IDictionary< TKey, TValue > PeanutButter.RandomGenerators.RandomValueGen.GetRandomDictionary< TKey, TValue > ( int minItems,
int maxItems )
static

Generates a random dictionary of the provided key / value types with at least {minItems} and at most {maxItems} in it.

Template Parameters
TKey
TValue
Returns

◆ GetRandomDomain()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomDomain ( )
static

Returns a random domain generated from a fairly common internet company name and one of the known TLDs at time of generation.

Returns

◆ GetRandomDouble() [1/3]

double PeanutButter.RandomGenerators.RandomValueGen.GetRandomDouble ( )
static

Produces a random double value between 0 and 10 inclusive.

Returns

◆ GetRandomDouble() [2/3]

double PeanutButter.RandomGenerators.RandomValueGen.GetRandomDouble ( double min,
double max )
static

Gets a random double value within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Double value within the specified range

◆ GetRandomDouble() [3/3]

double PeanutButter.RandomGenerators.RandomValueGen.GetRandomDouble ( double minValue)
static

Produces a random double value between the provides double value and that value + 10, inclusive.

Parameters
minValue
Returns

◆ GetRandomEmail() [1/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomEmail ( )
static

Gets a random email-like string. Note that this is only email-like in that it conforms to the structure: {random-string}random-string}.com.

Returns
Random email-like string

◆ GetRandomEmail() [2/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomEmail ( string firstName)
static

Gets a random email-like string. Note that this is only email-like in that it conforms to the structure: {random-string}random-string}.com

Parameters
firstNameUse a first-name to guide the process

Returns
Random email-like string

◆ GetRandomEmail() [3/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomEmail ( string firstName,
string lastName )
static

Gets a random email-like string. Note that this is only email-like in that it conforms to the structure: {random-string}random-string}.com

Parameters
firstNameUse a first-name to guide the process
lastNameUse a last-name to guide the process

Returns
Random email-like string

◆ GetRandomEnum< T >() [1/3]

T PeanutButter.RandomGenerators.RandomValueGen.GetRandomEnum< T > ( )
static

Gets a random enum value from the specified enum type.

Template Parameters
TType of enum to use as a source
Returns
Random enum value from the enum type
Exceptions
ArgumentExceptionThrown when GetRandomEnum is called on a non-enum type (since there is no generic constraint for enum types, yet)
Type Constraints
T :struct 
T :IConvertible 

◆ GetRandomEnum< T >() [2/3]

T PeanutButter.RandomGenerators.RandomValueGen.GetRandomEnum< T > ( Func< T, bool > validator)
static

Gets a random enum value from the specified enum type with validation for a required value.

Template Parameters
TType of enum to use as a source
Returns
Random enum value from the enum type
Exceptions
ArgumentExceptionThrown when GetRandomEnum is called on a non-enum type (since there is no generic constraint for enum types, yet)

◆ GetRandomEnum< T >() [3/3]

T PeanutButter.RandomGenerators.RandomValueGen.GetRandomEnum< T > ( params T[] excludingValues)
static

Gets a random enum value from the specified enum type. You may optionally specify enum values that you don't want in the output.

Template Parameters
TType of enum to use as a source
Returns
Random enum value from the enum type
Exceptions
ArgumentExceptionThrown when GetRandomEnum is called on a non-enum type (since there is no generic constraint for enum types, yet)
Type Constraints
T :struct 
T :IConvertible 

◆ GetRandomFileExtension()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomFileExtension ( )
static

Returns a random valid file extension.

Returns

◆ GetRandomFileName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomFileName ( )
static

Gets a random filename. Does not use the OS-level temporary filename functions.

Returns
String which is a random filename with a 3 character extension

◆ GetRandomFirstName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomFirstName ( )
static

Returns a random first name, sourced from unique top names:

  • male, international (100)
  • female, international (100)
  • south african (100)
Returns

◆ GetRandomFloat() [1/3]

float PeanutButter.RandomGenerators.RandomValueGen.GetRandomFloat ( )
static

Produces a random float between 0 and 10 inclusive.

Returns

◆ GetRandomFloat() [2/3]

float PeanutButter.RandomGenerators.RandomValueGen.GetRandomFloat ( float min,
float max )
static

Gets a random float value within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Float value within the specified range

◆ GetRandomFloat() [3/3]

float PeanutButter.RandomGenerators.RandomValueGen.GetRandomFloat ( float minValue)
static

Produces a random float between the provided minValue and that value + 10, inclusive.

Parameters
minValue
Returns

◆ GetRandomHttpMethod()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpMethod ( )
static

Returns a random http verb, ie one of.

  • DELETE
  • GET
  • HEAD
  • OPTIONS
  • POST
  • PUT
  • TRACE
Returns

◆ GetRandomHttpPathAndParameters()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpPathAndParameters ( )
static

Produces just the path and query string for an http request.

Returns

◆ GetRandomHttpsUrl()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpsUrl ( )
static

Generates a random string which looks a lot like an https url, to the domain only (no path or parameters)

Returns
Random Https-url-like string

◆ GetRandomHttpsUrlWithParameters()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpsUrlWithParameters ( )
static

Generates a random https url with some query parameters.

Returns

◆ GetRandomHttpsUrlWithPath()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpsUrlWithPath ( )
static

Produces a string which looks just like an https url with a path.

Returns

◆ GetRandomHttpsUrlWithPathAndParameters()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpsUrlWithPathAndParameters ( )
static

Produces a string that looks like an https url with path and parameters.

Returns

◆ GetRandomHttpUrl()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpUrl ( )
static

Generates a random string which looks a lot like an http url, to the domain only (no path or parameters)

Returns
Random http-url-like string

◆ GetRandomHttpUrlWithParameters()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpUrlWithParameters ( )
static

Generates a random HTTP url with some query parameters.

Returns

◆ GetRandomHttpUrlWithPath()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpUrlWithPath ( )
static

Produces a string which looks just like an http url with a path.

Returns

◆ GetRandomHttpUrlWithPathAndParameters()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomHttpUrlWithPathAndParameters ( )
static

Produces a string that looks like an http url with path and parameters.

Returns

◆ GetRandomInt() [1/3]

int PeanutButter.RandomGenerators.RandomValueGen.GetRandomInt ( )
static

Produces a random integer between 0 and 10 inclusive.

Returns

◆ GetRandomInt() [2/3]

int PeanutButter.RandomGenerators.RandomValueGen.GetRandomInt ( int minValue)
static

Produces an integer between the provided value and that value + 10, inclusive.

Parameters
minValue
Returns

◆ GetRandomInt() [3/3]

int PeanutButter.RandomGenerators.RandomValueGen.GetRandomInt ( int minValue,
int maxValue )
static

Returns a random integer within the specified range.

Parameters
minValueMinimum value to consider
maxValueMaximum value to consider
Returns
Random integer between minValue and maxValue (inclusive)

◆ GetRandomInterestRate() [1/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomInterestRate ( )
static

Produces a interest rate value (decimal with max 2 places) between 3 and 20 inclusive.

Returns

◆ GetRandomInterestRate() [2/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomInterestRate ( decimal min,
decimal max )
static

Gets a random interest rate value (decimal with max 2 places) within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Decimal value within the specified range

◆ GetRandomInterestRate() [3/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomInterestRate ( decimal minValue)
static

Produces a interest rate value (decimal with max 2 places) between of the provided minimum value up to that value.

  • 17
Parameters
minValue
Returns

◆ GetRandomIntKey() [1/2]

int PeanutButter.RandomGenerators.RandomValueGen.GetRandomIntKey ( )
static

Returns a random integer from 1 to 1000, as might be seen on an integer id field in a database.

Returns

◆ GetRandomIntKey() [2/2]

int PeanutButter.RandomGenerators.RandomValueGen.GetRandomIntKey ( int maxValue)
static

Returns a random integer from 1 to {maxValue}, as might be seen on an integer id field in a database.

Parameters
maxValue
Returns
Exceptions
ArgumentExceptionThrown if maxValue is provided < 2

◆ GetRandomLanguageCode()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomLanguageCode ( )
static

Provides a random language code.

Returns

◆ GetRandomLanguageName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomLanguageName ( )
static

Provides a random language name.

Returns

◆ GetRandomLastName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomLastName ( )
static

Returns a random last name, source from unique top names:

  • international (100)
  • african (100)
Returns

◆ GetRandomLong() [1/3]

long PeanutButter.RandomGenerators.RandomValueGen.GetRandomLong ( )
static

Produces a random long between 0 and 1000, inclusive.

Returns

◆ GetRandomLong() [2/3]

long PeanutButter.RandomGenerators.RandomValueGen.GetRandomLong ( long minValue)
static

Returns a random long between the provided min value and that value + 1000, inclusive.

Parameters
minValue
Returns

◆ GetRandomLong() [3/3]

long PeanutButter.RandomGenerators.RandomValueGen.GetRandomLong ( long minValue,
long maxValue )
static

Returns a random long within the specified range.

Parameters
minValueMinimum value to consider
maxValueMaximum value to consider
Returns
Random integer between minValue and maxValue (inclusive)

◆ GetRandomMIMEType()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomMIMEType ( )
static

Gets a pseudo-random mimetype (picks from a short list of known mime types)

Returns
String which is a valid mime type

◆ GetRandomMimeType()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomMimeType ( )
static

Gets a pseudo-random mimetype (picks from a short list of known mime types)

Returns
String which is a valid mime type

◆ GetRandomMoney() [1/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomMoney ( )
static

Produces a money value (decimal with max 2 places) between 10 and 100 inclusive.

Returns

◆ GetRandomMoney() [2/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomMoney ( decimal min,
decimal max )
static

Gets a random money value (decimal with max 2 places) within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Decimal value within the specified range

◆ GetRandomMoney() [3/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomMoney ( decimal minValue)
static

Produces a random decimal between the provided minValue and that value + 10, inclusive.

Parameters
minValue
Returns

◆ GetRandomName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomName ( )
static

Returns a random name of the format {FirstName} {LastName}.

Returns

◆ GetRandomNameValueCollection() [1/3]

NameValueCollection PeanutButter.RandomGenerators.RandomValueGen.GetRandomNameValueCollection ( )
static

Generates a random NameValueCollection with at least one item in it.

Returns

◆ GetRandomNameValueCollection() [2/3]

NameValueCollection PeanutButter.RandomGenerators.RandomValueGen.GetRandomNameValueCollection ( int minItems)
static

Generates a random NameValueCollection with at least {minItems} in it.

Returns

◆ GetRandomNameValueCollection() [3/3]

NameValueCollection PeanutButter.RandomGenerators.RandomValueGen.GetRandomNameValueCollection ( int minItems,
int maxItems )
static

Generates a random NameValueCollection with at least {minItems} and at most {maxItems} in it.

Returns

◆ GetRandomNonAlphaNumericString()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomNonAlphaNumericString ( int minChars = 0,
int maxChars = 10 )
static

Gets a random string made of non-alpha-numeric (but printable) chars.

Parameters
minChars
maxChars
Returns

◆ GetRandomNumericString()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomNumericString ( int minLength = DefaultRanges::MINLENGTH_STRING,
int? maxLength = null )
static

Gets a random string made up only of numeric characters.

Parameters
minLengthMinimum length required
maxLengthMaximum length required
Returns
Random string made up of only numeric characters

◆ GetRandomPath()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomPath ( )
static

Generates a random string which looks like a relative path on the internet or any reasonable filesystem.

Returns

◆ GetRandomPlaceName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomPlaceName ( )
static

Generates a random fantasy place name.

Returns

◆ GetRandomPostalCode()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomPostalCode ( )
static

Generates a random postal code.

Returns

◆ GetRandomStreetAddress() [1/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomStreetAddress ( )
static

Generates a street address.

Returns

◆ GetRandomStreetAddress() [2/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomStreetAddress ( string streetName)
static

Generates a street address, given a street name.

Parameters
streetName
Returns

◆ GetRandomStreetAddress() [3/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomStreetAddress ( string streetNumber,
string streetName )
static

Generates a street address, given a street number and / or name (null values are discarded & random values will be generated)

Parameters
streetNumber
streetName
Returns

◆ GetRandomStreetName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomStreetName ( )
static

Generates a street name.

Returns

◆ GetRandomStreetNumber()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomStreetNumber ( )
static

Generates a street number (eg 12 or 134a)

Returns

◆ GetRandomString()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomString ( int minLength = DefaultRanges::MINLENGTH_STRING,
int? maxLength = null,
string charSet = null )
static

Gets a random string.

Parameters
minLengthMinimum length required
maxLengthMaximum length required. When left null, will be the minimum length plus DefaultRanges.MINLENGTH_STRING
charSetCharacter set to use, as required
Returns
A new string which is between the minimum and maximum lengths (inclusive) and which is made up of the provided (or default, when not provided) character set

◆ GetRandomTaxRate() [1/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomTaxRate ( )
static

Produces a tax rate value (decimal with max 2 places) between 3 and 20 inclusive.

Returns

◆ GetRandomTaxRate() [2/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomTaxRate ( decimal min,
decimal max )
static

Gets a random tax rate value (decimal with max 2 places) within the specified range.

Parameters
minMinimum value to consider
maxMaximum value to consider
Returns
Decimal value within the specified range

◆ GetRandomTaxRate() [3/3]

decimal PeanutButter.RandomGenerators.RandomValueGen.GetRandomTaxRate ( decimal minValue)
static

Produces a tax rate value (decimal with max 2 places) between of the provided minimum value up to that value.

  • 17
Parameters
minValue
Returns

◆ GetRandomTimeOfDay() [1/3]

TimeSpan PeanutButter.RandomGenerators.RandomValueGen.GetRandomTimeOfDay ( )
static

Produces a random time of day.

Returns

◆ GetRandomTimeOfDay() [2/3]

TimeSpan PeanutButter.RandomGenerators.RandomValueGen.GetRandomTimeOfDay ( TimeSpan min)
static

Produces a random time of day from the provided minimum, inclusive.

Parameters
min
Returns

◆ GetRandomTimeOfDay() [3/3]

TimeSpan PeanutButter.RandomGenerators.RandomValueGen.GetRandomTimeOfDay ( TimeSpan min,
TimeSpan max )
static

Returns a random time of day.

Parameters
minMinimum time to consider
maxMaximum time to consider
Returns
Timespan representing a time on a day, clamped to within 24 hours

◆ GetRandomTimeSpan() [1/3]

TimeSpan PeanutButter.RandomGenerators.RandomValueGen.GetRandomTimeSpan ( )
static

Returns a random TimeSpan between TimeSpan.Z.

Returns

◆ GetRandomTimeSpan() [2/3]

TimeSpan PeanutButter.RandomGenerators.RandomValueGen.GetRandomTimeSpan ( double min,
double max = DefaultRanges::MAX_INT_VALUE,
TimeSpanContexts context = TimeSpanContexts::Minutes )
static

Gets a random timespan.

Parameters
minMinimum length
maxMaximum length
contextContext for the min/max length
Returns

◆ GetRandomTimeSpan() [3/3]

TimeSpan PeanutButter.RandomGenerators.RandomValueGen.GetRandomTimeSpan ( TimeSpan min,
TimeSpan? max = null )
static

Returns a TimeSpan between min and max.

Parameters
minmin timespan – defaults to TimeSpan.Zero
maxmax timespan – defaults to TimeSpan.MaxValue
Returns

◆ GetRandomTopLevelDomainName()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomTopLevelDomainName ( )
static

Returns a random.

Returns

◆ GetRandomType()

Type PeanutButter.RandomGenerators.RandomValueGen.GetRandomType ( )
static

Returns a random loaded type in the current app domain.

Returns

◆ GetRandomUrlParameters()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomUrlParameters ( )
static

Generates a string of random url parameters.

Returns

◆ GetRandomUrlQuery()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomUrlQuery ( )
static

Generates a random query string for an url.

Returns

◆ GetRandomUserName() [1/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomUserName ( )
static

Produces a random username:

  • will have a first name
  • will optionally have a .surname suffix
  • will optionally have a numeric suffix
Returns

◆ GetRandomUserName() [2/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomUserName ( string firstName)
static

Produces a random username:

  • will have a first name
  • will optionally have a .surname suffix
  • will optionally have a numeric suffix
    Parameters
    firstNameUse a first-name to guide the process
Returns

◆ GetRandomUserName() [3/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomUserName ( string firstName,
string lastName )
static

Produces a random username:

  • will have a first name
  • will optionally have a .surname suffix
  • will optionally have a numeric suffix
    Parameters
    firstNameUse a first-name to guide the process
    lastNameUse a last-name to guide the process
Returns

◆ GetRandomUtcDate() [1/2]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomUtcDate ( DateTime? minDate,
DateTime? maxDate,
bool dateOnly,
DateTime? minTime,
DateTime? maxTime )
static

Returns a random UTC date within the specified range.

Parameters
minDate
maxDate
dateOnly
minTime
maxTime
Returns

◆ GetRandomUtcDate() [2/2]

DateTime PeanutButter.RandomGenerators.RandomValueGen.GetRandomUtcDate ( DateTime? minDate = null,
DateTime? maxDate = null,
bool dateOnly = false,
TimeSpan? minTime = null,
TimeSpan? maxTime = null )
static

Returns a random UTC date within the specified range.

Parameters
minDate
maxDate
dateOnly
minTime
maxTime
Returns

◆ GetRandomUtcDateRange()

DateRange PeanutButter.RandomGenerators.RandomValueGen.GetRandomUtcDateRange ( DateTime? minDate = null,
DateTime? maxDate = null,
bool dateOnly = false,
DateTime? minTime = null,
DateTime? maxTime = null )
static

Gets a random Local DateTime range, by default within SQL-safe range.

Parameters
minDateMinimum date to consider
maxDateMaximum date to consider
dateOnlyFlag to determine if times should be truncated
minTimeMinimum time to consider (default all)
maxTimeMaximum time to consider (default all)
Returns
Random Local DateTime value

◆ GetRandomVersion()

Version PeanutButter.RandomGenerators.RandomValueGen.GetRandomVersion ( )
static

Gets a random System.Version instance.

Returns
New System.Version with random values

◆ GetRandomVersionString()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomVersionString ( int partCount = 3)
static

Gets a random version-like string (eg 1.2.3)

Parameters
partCountHow many parts to have in your version string
Returns
Version-like string

◆ GetRandomWindowsPath()

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomWindowsPath ( )
static

Gets a random path which resembles a Windows path, including a leading drive.

Returns
String which looks like a local Windows path

◆ GetRandomWords() [1/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomWords ( )
static

Produces a collection of words between 10 and 50 words in length, inclusive.

Returns

◆ GetRandomWords() [2/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomWords ( int minWords)
static

Produces a collection of words with count of at least minWords up to and including minWords + 50.

Parameters
minWords
Returns

◆ GetRandomWords() [3/3]

string PeanutButter.RandomGenerators.RandomValueGen.GetRandomWords ( int minWords,
int maxWords )
static

Gets some random pseudo-words. Note that they (probably) won't be readable words – just a collection of strings with whitespace in between. Think of this as something like Lorei Ipsum, except with zero meaning.

Parameters
minWordsMinimum number of "words" to return
maxWordsMaximum number of "words" to return
Returns
Block of text with "words" and whitespace

◆ InstallRandomGenerator< T >()

void PeanutButter.RandomGenerators.RandomValueGen.InstallRandomGenerator< T > ( Func< T > generator)
static

Add a special case for generating random values, eg for types which have no parameterless constructor, but, eg, may have a .Parse method NB: this method is NOT thread-safe when used concurrently with GetRandom<T>()

Parameters
generator

The documentation for this class was generated from the following file:
  • source/TestUtils/PeanutButter.RandomGenerators/RandomValueGen.cs