Coder Social home page Coder Social logo

murphy0202 / nmockaroo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amogram/nmockaroo

1.0 0.0 0.0 5.35 MB

NMockaroo is a little library that allows you to quickly generate mock data based on your C# objects using the Mockaroo API.

Home Page: https://github.com/amogram/NMockaroo

License: MIT License

C# 100.00%

nmockaroo's Introduction

NMockaroo

Build Status Version license

NMockaroo is a little library that provides an easy way for you to generate mock data based on your C# objects using the Mockaroo API.

Available on NuGet

Run the following command in the Package Manager Console:

PM> Install-Package NMockaroo

Example Usage

Suppose you have a Person object like this:

public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public string Role { get; set; }
}

Use the library of attributes in NMockaroo to define your Person Schema in Mockaroo:

public class Person
{
	[MockarooInfo(Type = DataTypes.FirstName)]
	public string FirstName { get; set; }

	[MockarooInfo(Type = DataTypes.LastName)]
	public string LastName { get; set; }

	[MockarooInfo(Type = DataTypes.EmailAddress, PercentBlank = 40)]
	public string Email { get; set; }

	[MockarooCustomList(
		PercentBlank = 0,
		Type = DataTypes.CustomList,
		Values = new[] { "Super User", "Administrator", "Manager", "Employee" },
		SelectionStyle = "sequential")]
	public string Role { get; set; }
}

Then use MockarooClient to generate your mock data:

var client = new MockarooClient(YOUR_API_KEY);
var people = client.GetData<Person>(10).ToArray();

Easy peasy.

Using NMockroo from behind a Web Proxy

From version 1.0.0, NMockaroo has web proxy support. When instantiating your MockarooClient object, you can declare your WebProxy details as follows:

var client = new MockarooClient(YOUR_API_KEY)
{
	Proxy = new WebProxy
	{
		Address = new Uri("http://web-proxy-url"),
		// ...
	}
};

Building on your own Machine

NMockaroo is a single assembly designed to be easy to deploy anywhere. If you prefer to compile it yourself, you will need:

  • Visual Studio 2015 (Community Edition is more than enough)
  • Windows 7 or newer

Contributing

NMockaroo is hosted on GitHub. If you find a bug, please visit the issue tracker and report the issue.

Feel free to submit a pull request containing any improvements, bug fixes or new features.

P.S. A huge thanks to Mockaroo, without which this library would not exist.

License

Copyright © 2016 Andrew McCaughan and other contributors.

Distributed under the MIT License.

Get more details at codescene.io.

nmockaroo's People

Contributors

amogram avatar bitdeli-chef avatar cannontrodder avatar dependabot-preview[bot] avatar dependabot-support avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.