Mirage 4.0.95

dotnet add package Mirage --version 4.0.95
NuGet\Install-Package Mirage -Version 4.0.95
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mirage" Version="4.0.95" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mirage --version 4.0.95
#r "nuget: Mirage, 4.0.95"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mirage as a Cake Addin
#addin nuget:?package=Mirage&version=4.0.95

// Install Mirage as a Cake Tool
#tool nuget:?package=Mirage&version=4.0.95

Mirage

.NET Publish

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 relies on Canister in order to hook itself up. In order for this to work, you must do the following at startup:

var MyServices = new ServiceCollection();
...
MyServices.AddCanisterModules();  // Should be last call in order to find any services that you might have added manually.
                                  // Any services added after this may not be found by the system.
				

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:

  1. Company
  2. Full Address
  3. City
  4. Domain name
  5. Email address
  6. Phone number
  7. State abbreviation
  8. State
  9. Zip Code
  10. Street Address
  11. Female/male first name
  12. Last name
  13. Female/Male name
  14. Female/male prefix
  15. Name suffix
  16. Full name generator that is male/female/either
  17. Lorem Ipsum
  18. Pattern based
  19. Regex based
  20. "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:

  1. Visual Studio 2017

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 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
4.0.95 312 4/12/2024
4.0.94 264 4/11/2024
4.0.93 277 4/10/2024
4.0.92 584 4/2/2024
4.0.91 272 3/29/2024
4.0.90 286 3/28/2024
4.0.89 738 3/18/2024
4.0.88 225 3/15/2024
4.0.87 252 3/14/2024
4.0.86 293 3/13/2024
4.0.85 434 3/11/2024
4.0.84 239 3/8/2024
4.0.83 276 3/7/2024
4.0.82 264 3/6/2024
4.0.81 282 3/5/2024
4.0.80 288 3/4/2024
4.0.79 745 2/29/2024
4.0.78 257 2/28/2024
4.0.77 246 2/27/2024
4.0.76 346 2/26/2024
4.0.75 105 2/23/2024
4.0.74 173 2/22/2024
4.0.73 111 2/22/2024
4.0.72 110 2/21/2024
4.0.71 111 2/21/2024
4.0.70 178 2/16/2024
4.0.69 240 2/14/2024
4.0.68 164 2/12/2024
4.0.67 137 2/9/2024
4.0.66 115 2/9/2024
4.0.65 139 2/7/2024
4.0.64 124 2/6/2024
4.0.63 1,859 2/5/2024
4.0.62 580 2/1/2024
4.0.61 100 1/31/2024
4.0.60 1,217 1/24/2024
4.0.59 194 1/24/2024
4.0.58 273 1/22/2024
4.0.57 718 1/11/2024
4.0.56 280 1/11/2024
4.0.55 1,153 12/27/2023
4.0.54 728 12/19/2023
4.0.53 538 12/14/2023
4.0.52 267 12/13/2023
4.0.51 204 12/12/2023
4.0.50 1,392 11/23/2023
4.0.49 316 11/21/2023
4.0.48 204 11/20/2023
4.0.47 222 11/17/2023
4.0.46 406 11/16/2023
4.0.45 247 11/15/2023
4.0.44 541 11/8/2023
4.0.43 215 11/7/2023
4.0.42 209 11/6/2023
4.0.41 252 11/4/2023
4.0.40 521 10/31/2023
4.0.39 241 10/30/2023
4.0.38 286 10/27/2023
4.0.37 246 10/26/2023
4.0.36 274 10/25/2023
4.0.35 629 10/12/2023
4.0.34 127 10/11/2023
4.0.33 673 9/25/2023
4.0.32 364 9/20/2023
4.0.31 234 9/19/2023
4.0.30 249 9/18/2023
4.0.29 443 9/14/2023
4.0.28 239 9/13/2023
4.0.27 257 9/12/2023
4.0.26 298 9/11/2023
4.0.25 109 9/11/2023
4.0.24 564 9/8/2023
4.0.23 289 9/7/2023
4.0.22 299 9/6/2023
4.0.21 328 9/4/2023
4.0.20 327 9/2/2023
4.0.19 121 9/1/2023
4.0.18 371 8/31/2023
4.0.17 496 8/29/2023
4.0.16 337 8/29/2023
4.0.15 530 8/24/2023
4.0.14 287 8/24/2023
4.0.13 293 8/22/2023
4.0.12 464 8/18/2023
4.0.11 1,422 8/9/2023
4.0.10 305 8/8/2023
4.0.9 183 8/8/2023
4.0.8 395 8/7/2023
4.0.7 205 8/4/2023
4.0.6 372 8/2/2023
4.0.5 305 7/27/2023
4.0.4 252 7/25/2023
4.0.3 350 7/20/2023
4.0.2 435 7/14/2023
4.0.1 718 12/13/2022
4.0.0 1,972 12/12/2022
3.0.19 2,746 6/10/2022
3.0.17 831 2/17/2022
3.0.16 447 2/3/2022
3.0.15 2,324 1/11/2022
3.0.14 2,156 7/22/2021
3.0.13 340 7/22/2021
3.0.11 342 7/20/2021
3.0.10 570 6/16/2021
3.0.9 906 6/16/2021
3.0.8 6,552 1/6/2021
3.0.6 2,790 9/13/2020
3.0.5 7,624 3/25/2020
3.0.4 1,565 3/18/2020
3.0.3 543 3/17/2020
3.0.2 551 3/17/2020
3.0.1 1,527 3/1/2020
3.0.0 3,066 12/23/2019
2.0.12 1,461 3/12/2019
2.0.11 632 3/12/2019
2.0.10 1,309 2/21/2019
2.0.9 3,005 8/14/2018
2.0.8 1,484 8/10/2018
2.0.7 888 8/9/2018
2.0.6 911 8/9/2018
2.0.5 943 8/9/2018
2.0.4 975 8/8/2018
2.0.3 1,069 8/8/2018
2.0.2 3,383 6/1/2018
2.0.1 1,816 5/22/2018
2.0.0 4,357 1/2/2018
1.0.10 13,873 6/13/2017
1.0.9 1,652 5/17/2017
1.0.8 1,059 3/22/2017
1.0.7 1,048 2/21/2017
1.0.5 1,100 2/8/2017
1.0.4 1,120 2/7/2017
1.0.3 1,130 2/6/2017
1.0.2 1,066 1/24/2017
1.0.1 1,095 1/18/2017