Master | Development | |
---|---|---|
Build Status: |
Mockaroo.NET is a portable class library that allows you to generate sample data based on C# objects using the Mockaroo REST API.
Lets say you have the following class.
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
}
Now you want to generate a collection Employee objects to do some testing. All you have to do is.
var client = new MockarooClient(your_api_key);
IEnumerable<Employee> data = await client.FetchDataAsync<Employee>(records: 100);
This will examine the Employee class properties, then generate random sample objects using the data fetched from the Mockaroo Rest API. The data returned will look something like the following.
[{
"Id": "156",
"Name": "aliquam erat volutpat in congue etiam",
"Phone": "adipiscing molestie hendrerit at vulputate"
}]
If Lorem Ipsum text is not to your liking, you can fine-tune the data returned using the following.
var schema = new Schema<Employee>();
schema.Assign(x=> x.Name, DataType.FullName);
schema.Assign(x=> x.Phone, new PhoneField() { BlankPercentage = 50 });
var client = new MockarooClient(your_api_key);
IEnumerable<Employee> data = await client.FetchDataAsync<Employee>(schema, records: 1000);
The results will look like the following.
[{
"Id": "156",
"Name": "John Doe",
"Phone": "(340) 123-4567"
}]
Currently there are over 85+ data types to choose from, check out the Mockaroo documentation to see the full list. You can also try it at https://www.mockaroo.com/
PM> Install-Package Gigobyte.Mockaroo.Core
- Visual Studio 2015
- Mockaroo API Key
Note:
Mockaroo.NET is Copyright © 2015 Ackara and other contributors under the MIT License.