Table of Contents

Class Random

Namespace
CarinaStudio.Tests
Assembly
CarinaStudio.AppBase.Tests.dll

Provide random functions for testing.

public static class Random
Inheritance
Random
Inherited Members

Methods

CreateFileWithRandomName(DirectoryInfo)

Create new file with random file name.

public static FileStream CreateFileWithRandomName(DirectoryInfo directory)

Parameters

directory DirectoryInfo

Directory to create file in.

Returns

FileStream

FileStream of generated file.

CreateFileWithRandomName(string)

Create new file with random file name.

public static FileStream CreateFileWithRandomName(string directoryName)

Parameters

directoryName string

Name of directory to create file in.

Returns

FileStream

FileStream of generated file.

GenerateRandomString(int)

Generate string contains random characters.

public static string GenerateRandomString(int length)

Parameters

length int

Length of string.

Returns

string

Generated string.

Remarks

Characters will be seleced randomly from '0' to '9' and 'a' to 'z'.

Next()

Get a random non-negative integer.

public static int Next()

Returns

int

Random integer.

Next(int)

Get a random non-negative integer.

public static int Next(int maxValue)

Parameters

maxValue int

Maximum exclusive integer to get.

Returns

int

Random integer.

Next(int, int)

Get a random integer.

public static int Next(int minValue, int maxValue)

Parameters

minValue int

Minimum inclusive interger to get.

maxValue int

Maximum exclusive integer to get.

Returns

int

Random integer.

NextBytes(byte[])

Fill random values into given buffer.

public static void NextBytes(byte[] buffer)

Parameters

buffer byte[]

Buffer to fill random values.

NextBytes(Span<byte>)

Fill random values into given buffer.

public static void NextBytes(Span<byte> buffer)

Parameters

buffer Span<byte>

Buffer to fill random values.

NextDouble()

Get a random double from [0.0, 1.0).

public static double NextDouble()

Returns

double

Random double.