Jds.TestingUtils.Randomization
0.0.0-build-20220202-013346-sha-0d1ab24
See the version list below for details.
dotnet add package Jds.TestingUtils.Randomization --version 0.0.0-build-20220202-013346-sha-0d1ab24
NuGet\Install-Package Jds.TestingUtils.Randomization -Version 0.0.0-build-20220202-013346-sha-0d1ab24
<PackageReference Include="Jds.TestingUtils.Randomization" Version="0.0.0-build-20220202-013346-sha-0d1ab24" />
<PackageVersion Include="Jds.TestingUtils.Randomization" Version="0.0.0-build-20220202-013346-sha-0d1ab24" />
<PackageReference Include="Jds.TestingUtils.Randomization" />
paket add Jds.TestingUtils.Randomization --version 0.0.0-build-20220202-013346-sha-0d1ab24
#r "nuget: Jds.TestingUtils.Randomization, 0.0.0-build-20220202-013346-sha-0d1ab24"
#:package Jds.TestingUtils.Randomization@0.0.0-build-20220202-013346-sha-0d1ab24
#addin nuget:?package=Jds.TestingUtils.Randomization&version=0.0.0-build-20220202-013346-sha-0d1ab24&prerelease
#tool nuget:?package=Jds.TestingUtils.Randomization&version=0.0.0-build-20220202-013346-sha-0d1ab24&prerelease
Testing Utils: Randomization
This collection of randomization test utilities supports creating test arrangements.
How to Use
All examples below use the thread-safe, static
Jds.TestingUtils.Randomization.Randomizer.Sharedinstance ofIRandomizationSource, which generates random values usingSystem.Random.Shared. ThisIRandomizationSourceis advised for most tests.If a different algorithm is needed, e.g., a cryptographically strong random number generator is required, consider creating a
Jds.TestingUtils.Randomization.ArrangedRandomizationSource. It uses providedFunc<IEnumerable<>>delegates to supply values when requested.If a specific set of random-seeming data is needed, consider creating a
Jds.TestingUtils.Randomization.DeterministicRandomizationSource. It uses providedIEnumerable<>sources to supply values when requested.
Generate Pseudo-random Numbers
IRandomizationSource.Byte()- Gets a pseudo-random
byte, greater than or equal tobyte.MinValue, and less thanbyte.MaxValue.
- Gets a pseudo-random
IRandomizationSource.ByteInRange(byte minInclusive, byte maxExclusive)- Gets a pseudo-random
byte, greater than or equal tominInclusive, and less thanmaxExclusive.
- Gets a pseudo-random
IRandomizationSource.Double()- Gets a pseudo-random
double, usingIRandomizationSource.NextDouble. The value should be greater than or equal to0.0, and less than1.0.
- Gets a pseudo-random
IRandomizationSource.Float()- Gets a pseudo-random
float, usingIRandomizationSource.NextFloat. The value should be greater than or equal to0.0, and less than1.0.
- Gets a pseudo-random
IRandomizationSource.Int()- Gets a pseudo-random
int, usingIRandomizationSource.NextIntInRange. The value should be greater than or equal toint.MinValue, and less thanint.MaxValue.
- Gets a pseudo-random
IRandomizationSource.IntInRange(int minInclusive, int maxExclusive)- Gets a pseudo-random
int, usingIRandomizationSource.NextIntInRange. The value should be greater than or equal tominInclusive, and less thanmaxExclusive.
- Gets a pseudo-random
IRandomizationSource.IntNegative()- Gets a pseudo-random
int, usingIRandomizationSource.NextIntInRange. The value should be greater than or equal toint.MinValue, and less than0.
- Gets a pseudo-random
IRandomizationSource.IntPositive()- Gets a pseudo-random
int, usingIRandomizationSource.NextIntInRange. The value should be greater than or equal to0, and less thanint.MaxValue.
- Gets a pseudo-random
IRandomizationSource.Long()- Gets a pseudo-random
long, usingIRandomizationSource.NextLongInRange. The value should be greater than or equal tolong.MinValue, and less thanlong.MaxValue.
- Gets a pseudo-random
IRandomizationSource.LongInRange(long minInclusive, long maxExclusive)- Gets a pseudo-random
long, usingIRandomizationSource.NextLongInRange. The value should be greater than or equal tominInclusive, and less thanmaxExclusive.
- Gets a pseudo-random
IRandomizationSource.LongNegative()- Gets a pseudo-random
long, usingIRandomizationSource.NextLongInRange. The value should be greater than or equal tolong.MinValue, and less than0.
- Gets a pseudo-random
IRandomizationSource.LongPositive()- Gets a pseudo-random
long, usingIRandomizationSource.NextLongInRange. The value should be greater than or equal to0, and less thanlong.MaxValue.
- Gets a pseudo-random
Select a Random Item or Enumeration Value
IRandomizationSource.RandomEnumValue<TEnum>()- Selects a pseudo-random value from the
enumof type specified (TEnum). - Example:
Jds.TestingUtils.Randomization.Randomizer.Shared.RandomEnumValue<System.Net.HttpStatusCode>()
- Selects a pseudo-random value from the
IRandomizationSource.RandomListItem<T>(IReadOnlyList<T> items)- Selects a pseudo-random item from provided
items. - Example:
Jds.TestingUtils.Randomization.Randomizer.Shared.RandomListItem(System.Linq.Enumerable.Range(1, 20).ToArray())
- Selects a pseudo-random item from provided
Generate a Random String
IRandomizationSource.RandomString(int length, IReadOnlyList<char> chars)- Generates a random
stringoflengthcharacters, using providedchars. Random selections fromcharsare concatenated until reachinglengthcharacters.
- Generates a random
IRandomizationSource.RandomString(int length, IReadOnlyList<string> strings)- Generates a random
stringoflengthcharacters, using providedstrings. Random selections fromstringsare concatenated until reachinglengthcharacters. The result is truncated tolengthcharacters.
- Generates a random
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 0.9.0 | 2,386 | 10/5/2024 | |
| 0.8.0 | 1,393 | 6/25/2024 | |
| 0.7.0 | 1,066 | 11/12/2023 | |
| 0.6.0 | 4,172 | 5/16/2023 | |
| 0.5.0 | 1,056 | 1/10/2023 | |
| 0.5.0-build-20220414-050254... | 342 | 4/14/2022 | |
| 0.4.0 | 1,510 | 2/19/2022 | |
| 0.4.0-build-20220214-011232... | 314 | 2/14/2022 | |
| 0.3.0 | 648 | 2/14/2022 | |
| 0.3.0-build-20220214-010752... | 342 | 2/14/2022 | |
| 0.3.0-build-20220214-004124... | 351 | 2/14/2022 | |
| 0.3.0-build-20220208-010440... | 341 | 2/8/2022 | |
| 0.2.0 | 558 | 2/8/2022 | |
| 0.2.0-build-20220208-005756... | 329 | 2/8/2022 | |
| 0.2.0-build-20220206-223707... | 326 | 2/6/2022 | |
| 0.2.0-build-20220206-212627... | 352 | 2/6/2022 | |
| 0.2.0-build-20220204-031004... | 377 | 2/4/2022 | |
| 0.1.0 | 632 | 2/4/2022 | |
| 0.1.0-build-20220204-024107... | 349 | 2/4/2022 | |
| 0.0.0-build-20220204-022926... | 350 | 2/4/2022 | |
| 0.0.0-build-20220204-021830... | 351 | 2/4/2022 | |
| 0.0.0-build-20220202-013346... | 377 | 2/2/2022 |