Mirage 5.0.1
dotnet add package Mirage --version 5.0.1
NuGet\Install-Package Mirage -Version 5.0.1
<PackageReference Include="Mirage" Version="5.0.1" />
paket add Mirage --version 5.0.1
#r "nuget: Mirage, 5.0.1"
// Install Mirage as a Cake Addin #addin nuget:?package=Mirage&version=5.0.1 // Install Mirage as a Cake Tool #tool nuget:?package=Mirage&version=5.0.1
Mirage
Mirage is an open source library for .Net designed to create random data for POCOs, unit tests, etc. Supports .Net Core as well as full .Net.
Setting Up the Library
Mirage hooks itself up and is usable via your apps service collection. In order for this to work, you must do the following at startup:
var MyServices = new ServiceCollection();
...
MyServices.RegisterMirage();
Or if you are using Canister:
MyServices.AddCanisterModules();
When this is done, Mirage is ready to use.
Basic Usage
The main class of interest is the Random class:
Mirage.Random RandomObj = new Mirage.Random();
This class has a number of helper functions including a generic Next function:
RandomObj.Next<short>();
RandomObj.Next<float>();
RandomObj.Next<TimeSpan>();
You can also Specify a number of items that you want returned:
var MyList = RandomObj.Next<short>(4);
The MyList object would contain four shorts. You can similarly pull a random item from a list:
var Item = RandomObj.Next(MyList);
This would return a random short from the MyList object specified above. Or you can simply shuffle a list into a random order:
MyList = RandomObj.Shuffle(MyList);
There is also a thread safe version of Next that is available:
var RandomValue=RandomObj.ThreadSafeNext();
Lastly you can randomly generate an entire class as needed:
public class RandomTestClass
{
[IntGenerator(-100, 100)]
public int A { get; set; }
[LoremIpsum]
public string B { get; set; }
[FloatGenerator(0, 1)]
public float C { get; set; }
[IntGenerator(1, 100)]
public int D { get; set; }
}
...
var Rand = new Mirage.Random();
var Class = Rand.Next<RandomTestClass>();
This will create an object of the type specified and randomly assign values to the properties based on the attributes placed on them. The system has one for all of the basic types as well as a number of string generators including:
- Company
- Full Address
- City
- Domain name
- Email address
- Phone number
- State abbreviation
- State
- Zip Code
- Street Address
- Female/male first name
- Last name
- Female/Male name
- Female/male prefix
- Name suffix
- Full name generator that is male/female/either
- Lorem Ipsum
- Pattern based
- Regex based
- "Problem" strings
Adding Your Own Generator
You may wish to create your own random generator or replace one that is already in the system. In order to do this simply create a class that implements the IGenerator class. Simply specify in the class what type it generates and the system will either add it to the list of generators or replace the existing one with your own. As long as you either don't specify which modules to load or include your target assembly when calling AddCanisterModules, the system will then pick it up automatically and call it as requested. Similarly if you wish for it to be picked up when generating a class, make sure your class inherits from GeneratorAttributeBase. If it does, the random class generation will pick it up.
Installation
The library is available via Nuget with the package name "Mirage". To install it run the following command in the Package Manager Console:
Install-Package Mirage
Build Process
In order to build the library you will require the following:
- Visual Studio 2022
Other than that, just clone the project and you should be able to load the solution and build without too much effort.
Other Info
The problem strings generator is based off of the Max Woolf's "Big List of Naughty Strings" which is MIT licensed.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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 is compatible. |
-
net8.0
- BigBook (>= 6.0.3)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.ValueTuple (>= 4.5.0)
-
net9.0
- BigBook (>= 6.0.3)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.ValueTuple (>= 4.5.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Mirage:
Package | Downloads |
---|---|
Inflatable
Inflatable is a simple ORM. |
|
Mecha.Core
Mecha is a C# library that enables automatic testing of classes with the goal of finding ways to break the code. It provides various testing capabilities such as unit testing, security testing through data fuzzing, checking for concurrency issues, and verifying fault tolerance. With just a single line of code, Mecha can automatically test every method in a class. The library seamlessly integrates with your existing testing framework. |
|
TestFountain
TestFountain is a set of addons/extensions for xUnit.net to help with things like data generation. |
|
sundial.core
Sundial is a profiler library used for both comparison of multiple bits of code and hot spot detection. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
5.0.1 | 297 | 12/10/2024 |
5.0.0 | 1,465 | 11/24/2024 |
4.1.13 | 5,245 | 9/24/2024 |
4.1.12 | 2,130 | 8/29/2024 |
4.1.11 | 397 | 8/26/2024 |
4.1.10 | 304 | 8/24/2024 |
4.1.9 | 791 | 8/21/2024 |
4.1.8 | 704 | 8/19/2024 |
4.1.7 | 659 | 8/14/2024 |
4.1.6 | 777 | 8/3/2024 |
4.1.5 | 981 | 7/24/2024 |
4.1.4 | 696 | 7/10/2024 |
4.1.3 | 1,450 | 6/27/2024 |
4.1.2 | 319 | 6/25/2024 |
4.1.1 | 680 | 6/21/2024 |
4.1.0 | 246 | 6/21/2024 |
4.0.109 | 358 | 6/19/2024 |
4.0.108 | 367 | 6/18/2024 |
4.0.107 | 593 | 6/13/2024 |
4.0.106 | 330 | 6/13/2024 |
4.0.105 | 983 | 5/30/2024 |
4.0.104 | 353 | 5/30/2024 |
4.0.103 | 1,307 | 5/16/2024 |
4.0.102 | 305 | 5/16/2024 |
4.0.101 | 774 | 5/7/2024 |
4.0.100 | 366 | 5/6/2024 |
4.0.99 | 677 | 5/2/2024 |
4.0.98 | 289 | 5/2/2024 |
4.0.97 | 107 | 5/2/2024 |
4.0.96 | 446 | 4/29/2024 |
4.0.95 | 1,121 | 4/12/2024 |
4.0.94 | 340 | 4/11/2024 |
4.0.93 | 333 | 4/10/2024 |
4.0.92 | 665 | 4/2/2024 |
4.0.91 | 343 | 3/29/2024 |
4.0.90 | 399 | 3/28/2024 |
4.0.89 | 898 | 3/18/2024 |
4.0.88 | 280 | 3/15/2024 |
4.0.87 | 318 | 3/14/2024 |
4.0.86 | 362 | 3/13/2024 |
4.0.85 | 519 | 3/11/2024 |
4.0.84 | 294 | 3/8/2024 |
4.0.83 | 352 | 3/7/2024 |
4.0.82 | 325 | 3/6/2024 |
4.0.81 | 343 | 3/5/2024 |
4.0.80 | 353 | 3/4/2024 |
4.0.79 | 848 | 2/29/2024 |
4.0.78 | 310 | 2/28/2024 |
4.0.77 | 296 | 2/27/2024 |
4.0.76 | 437 | 2/26/2024 |
4.0.75 | 145 | 2/23/2024 |
4.0.74 | 231 | 2/22/2024 |
4.0.73 | 153 | 2/22/2024 |
4.0.72 | 152 | 2/21/2024 |
4.0.71 | 153 | 2/21/2024 |
4.0.70 | 234 | 2/16/2024 |
4.0.69 | 316 | 2/14/2024 |
4.0.68 | 234 | 2/12/2024 |
4.0.67 | 184 | 2/9/2024 |
4.0.66 | 173 | 2/9/2024 |
4.0.65 | 205 | 2/7/2024 |
4.0.64 | 174 | 2/6/2024 |
4.0.63 | 2,080 | 2/5/2024 |
4.0.62 | 676 | 2/1/2024 |
4.0.61 | 153 | 1/31/2024 |
4.0.60 | 1,769 | 1/24/2024 |
4.0.59 | 252 | 1/24/2024 |
4.0.58 | 337 | 1/22/2024 |
4.0.57 | 849 | 1/11/2024 |
4.0.56 | 335 | 1/11/2024 |
4.0.55 | 1,302 | 12/27/2023 |
4.0.54 | 876 | 12/19/2023 |
4.0.53 | 635 | 12/14/2023 |
4.0.52 | 321 | 12/13/2023 |
4.0.51 | 255 | 12/12/2023 |
4.0.50 | 1,525 | 11/23/2023 |
4.0.49 | 389 | 11/21/2023 |
4.0.48 | 251 | 11/20/2023 |
4.0.47 | 289 | 11/17/2023 |
4.0.46 | 644 | 11/16/2023 |
4.0.45 | 304 | 11/15/2023 |
4.0.44 | 651 | 11/8/2023 |
4.0.43 | 274 | 11/7/2023 |
4.0.42 | 263 | 11/6/2023 |
4.0.41 | 321 | 11/4/2023 |
4.0.40 | 622 | 10/31/2023 |
4.0.39 | 291 | 10/30/2023 |
4.0.38 | 340 | 10/27/2023 |
4.0.37 | 302 | 10/26/2023 |
4.0.36 | 336 | 10/25/2023 |
4.0.35 | 743 | 10/12/2023 |
4.0.34 | 173 | 10/11/2023 |
4.0.33 | 781 | 9/25/2023 |
4.0.32 | 447 | 9/20/2023 |
4.0.31 | 296 | 9/19/2023 |
4.0.30 | 313 | 9/18/2023 |
4.0.29 | 519 | 9/14/2023 |
4.0.28 | 302 | 9/13/2023 |
4.0.27 | 328 | 9/12/2023 |
4.0.26 | 354 | 9/11/2023 |
4.0.25 | 141 | 9/11/2023 |
4.0.24 | 649 | 9/8/2023 |
4.0.23 | 340 | 9/7/2023 |
4.0.22 | 367 | 9/6/2023 |
4.0.21 | 395 | 9/4/2023 |
4.0.20 | 381 | 9/2/2023 |
4.0.19 | 156 | 9/1/2023 |
4.0.18 | 432 | 8/31/2023 |
4.0.17 | 577 | 8/29/2023 |
4.0.16 | 400 | 8/29/2023 |
4.0.15 | 610 | 8/24/2023 |
4.0.14 | 368 | 8/24/2023 |
4.0.13 | 352 | 8/22/2023 |
4.0.12 | 537 | 8/18/2023 |
4.0.11 | 1,964 | 8/9/2023 |
4.0.10 | 364 | 8/8/2023 |
4.0.9 | 228 | 8/8/2023 |
4.0.8 | 457 | 8/7/2023 |
4.0.7 | 259 | 8/4/2023 |
4.0.6 | 441 | 8/2/2023 |
4.0.5 | 379 | 7/27/2023 |
4.0.4 | 313 | 7/25/2023 |
4.0.3 | 424 | 7/20/2023 |
4.0.2 | 535 | 7/14/2023 |
4.0.1 | 791 | 12/13/2022 |
4.0.0 | 2,040 | 12/12/2022 |
3.0.19 | 2,873 | 6/10/2022 |
3.0.17 | 876 | 2/17/2022 |
3.0.16 | 488 | 2/3/2022 |
3.0.15 | 2,441 | 1/11/2022 |
3.0.14 | 2,292 | 7/22/2021 |
3.0.13 | 378 | 7/22/2021 |
3.0.11 | 384 | 7/20/2021 |
3.0.10 | 628 | 6/16/2021 |
3.0.9 | 964 | 6/16/2021 |
3.0.8 | 6,948 | 1/6/2021 |
3.0.6 | 2,932 | 9/13/2020 |
3.0.5 | 7,901 | 3/25/2020 |
3.0.4 | 1,625 | 3/18/2020 |
3.0.3 | 578 | 3/17/2020 |
3.0.2 | 586 | 3/17/2020 |
3.0.1 | 1,595 | 3/1/2020 |
3.0.0 | 3,209 | 12/23/2019 |
2.0.12 | 1,518 | 3/12/2019 |
2.0.11 | 674 | 3/12/2019 |
2.0.10 | 1,386 | 2/21/2019 |
2.0.9 | 3,129 | 8/14/2018 |
2.0.8 | 1,607 | 8/10/2018 |
2.0.7 | 937 | 8/9/2018 |
2.0.6 | 960 | 8/9/2018 |
2.0.5 | 998 | 8/9/2018 |
2.0.4 | 1,025 | 8/8/2018 |
2.0.3 | 1,115 | 8/8/2018 |
2.0.2 | 3,496 | 6/1/2018 |
2.0.1 | 1,880 | 5/22/2018 |
2.0.0 | 4,517 | 1/2/2018 |
1.0.10 | 14,304 | 6/13/2017 |
1.0.9 | 1,728 | 5/17/2017 |
1.0.8 | 1,098 | 3/22/2017 |
1.0.7 | 1,105 | 2/21/2017 |
1.0.5 | 1,140 | 2/8/2017 |
1.0.4 | 1,166 | 2/7/2017 |
1.0.3 | 1,178 | 2/6/2017 |
1.0.2 | 1,113 | 1/24/2017 |
1.0.1 | 1,132 | 1/18/2017 |