A randomization library for .NET
(inspired by the chance.js library)
Over 70 different things to randomize!
PM> Install-Package IncidentCS
Check the wiki for the list of available randomizers or see the example below for the quick start.
Note that the example shows only a small subset of randomization areas.
- Primitives (numbers, strings, etc.)
- Textual elements (words, sentences and paragraphs)
- LoremIpsum
- Human related (names, birthdays, etc.)
- Web elements (domains, urls, colors)
- Business data (phones, companies)
- Schools, Universities
- Games related
- Geographic data
// Ensures random textual content (i.e. names, words) to be in English language
Incident.Culture = new CultureInfo("en-US");
var roles = Incident.Utils.CreateWheel(new Dictionary<string, double>()
{
// 3 in 100 are bosses
{ "Boss", 3 },
// 12 in 100 are managers
{ "Manager", 12 },
// 85 in 100 (the rest) are workers
{ "Worker", 85 }
});
// Randomize a user
var user = new User()
{
Name = Incident.Human.FullName,
Birthday = Incident.Human.Birthday(HumanAgeCategory.Adult),
Phone = Incident.Business.Phone,
Address = new Address()
{
Street = Incident.Primitive.IntegerBetween(10, 1000) + " " + Incident.Geo.Street,
City = Incident.Geo.City,
ZIP = Incident.Geo.ZIP,
Country = Incident.Geo.Country
},
Company = Incident.Business.Company,
Role = roles.RandomElement,
Twitter = Incident.Web.Twitter,
FavoriteHashTag = Incident.Web.Hashtag,
FavoriteColor = Incident.Web.HexColor,
FavoriteQuote = Incident.Text.Sentence
};
You are welcome to add localized randomizers or suggest an improvement. Send me a pull request.
- Consider using Mersene Twister instead of System.Random