GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - exceptionless/Exceptionless.RandomData: Utility class to easily generate random data.

BranchesTags
Open more actions menu

Latest commit

 

History

152 Commits
152 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
build
build
 
 
src/Exceptionless.RandomData
src/Exceptionless.RandomData
 
 
test/Exceptionless.RandomData.Tests
test/Exceptionless.RandomData.Tests
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
Exceptionless.RandomData.slnx
Exceptionless.RandomData.slnx
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
global.json
global.json
 
 

Repository files navigation

Exceptionless.RandomData

Build status NuGet Version Discord Donate

A utility library for generating random data in .NET. Makes generating realistic test data a breeze. Targets net8.0 and net10.0.

Getting Started

This package can be installed via the NuGet package manager. If you need help, please contact us via in-app support or open an issue. We're always here to help if you have any questions!

dotnet add package Exceptionless.RandomData

Usage

All methods are on the static RandomData class in the Exceptionless namespace.

Numbers

using Exceptionless;

int value = RandomData.GetInt(1, 100);
long big = RandomData.GetLong(0, 1_000_000);
double d = RandomData.GetDouble(0.0, 1.0);
decimal m = RandomData.GetDecimal(1, 500);

Booleans

using Exceptionless;

bool coin = RandomData.GetBool();
bool likely = RandomData.GetBool(chance: 80); // 80% chance of true

Strings

using Exceptionless;

string random = RandomData.GetString(minLength: 5, maxLength: 20);
string alpha = RandomData.GetAlphaString(10, 10);
string alphaNum = RandomData.GetAlphaNumericString(8, 16);

Words, Sentences, and Paragraphs

using Exceptionless;

string word = RandomData.GetWord();
string title = RandomData.GetTitleWords(minWords: 3, maxWords: 6);
string sentence = RandomData.GetSentence(minWords: 5, maxWords: 15);
string text = RandomData.GetParagraphs(count: 2, minSentences: 3, maxSentences: 10);
string html = RandomData.GetParagraphs(count: 2, html: true);

Dates and Times

using Exceptionless;

DateTime date = RandomData.GetDateTime();
DateTime recent = RandomData.GetDateTime(start: DateTime.UtcNow.AddDays(-30), end: DateTime.UtcNow);
DateTimeOffset dto = RandomData.GetDateTimeOffset();
TimeSpan span = RandomData.GetTimeSpan(min: TimeSpan.FromMinutes(1), max: TimeSpan.FromHours(2));

Enums

using Exceptionless;

DayOfWeek day = RandomData.GetEnum<DayOfWeek>();

Network and Versioning

using Exceptionless;

string ip = RandomData.GetIp4Address();           // e.g. "192.168.4.12"
string coord = RandomData.GetCoordinate();         // e.g. "45.123,-90.456"
string version = RandomData.GetVersion("1.0", "5.0");

Pick Random from Collection

The Random<T>() extension method picks a random element from any IEnumerable<T>:

using Exceptionless;

int[] numbers = [1, 2, 3, 4, 5];
int picked = numbers.Random();

string[] names = ["Alice", "Bob", "Charlie"];
string? name = names.Random();

Thanks to all the people who have contributed

contributors

About

Utility class to easily generate random data.

www.nuget.org/packages/Exceptionless.RandomData/

Topics

c-sharpexceptionlessrandomrandom-number-generatorsrandomdatarandomization

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

13 stars

Watchers

4 watching

Forks

6 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.