An open API service indexing awesome lists of open source software.

https://github.com/anuviswan/mockcollection

Randomize.Net - Generate Random Instances/Collections of any type <T>
https://github.com/anuviswan/mockcollection

Last synced: about 1 year ago
JSON representation

Randomize.Net - Generate Random Instances/Collections of any type <T>

Awesome Lists containing this project

README

          

**Randomize.Net**

Randomize.Net provides an easy and lightweight extensions for **System.Random** for creating random instances of any type, with generated random value. The whole idea behind Randomize.Net is extend the much familiar System.Random syntax for generating random collections rather than reinventing the wheel with a new syntax.

For Example,

```csharp
var _random = new Random();_
var randomString = _random.GenerateInstance();
var randomInt32 = _random.GenerateInstance();
```

Randomize.Net works with User Defined Types as well, including nested User Defined Types.

```csharp
public class SampleClass
{
public string StringProperty{get;set;}
public int Int32Property {get;set;}
public char CharProperty {get;set;}
}

public class AnotherSampleClass
{
public SampleClass SampleClassProperty{get;set;}
public string StringProperty{get;set;}
}

var sampleClass = _random.GenerateInstance();
var anotherSampleClass = _random.GenerateInstance();
```

*Randomize.Net* also supports generation of Collections.

```csharp
// Method Signature
public static IEnumerable GenerateCollection(this Random source,int count = 1)

//Example
var sampleClassCollection = _random.GenerateCollection(10);
```