Data generation

Generation of an entire response

Set response.randomize flag to true if you need to generate a random response. Also, please note that:

  • The flag is ignored if response.body or response.stream section is present. Explicit mapping has a higher priority
  • Only response.body or response.stream sections are randomized, response.header section remains untouched. You should provide response.header mapping explicitly if required
  • Randomization works for gRPS API only. HTTP mock does not support response.randomize because it lacks data schema

Basic example:

---
fileVersion: v1
instanceName: eShop
protoFile: "/grpc-examples/eShop/protos/catalog.proto"
calls:
- method: CatalogApi.Catalog/GetItemById
  response:
    randomize: true # generate random response
    status: OK

and if you want to specify a response header:

- method: CatalogApi.Catalog/GetItemById
  response:
    header:
      Expires: "{{ date.now | date.add_days 2 | date.to_string '%a, %d %b %Y %T %Z' }}"
    randomize: true # generate random response
    status: OK

Generation of an arbitrary field

Mock.qa provides a data faker that generates realistic data in responses for testing needs. There are many datasets, that are described below. Many thanks to Bogus for .NET library by Brian Chavez, which is behind the mock.qa data faker.

General usage syntax:

property: "{{ faker.<dataset>.<method> [param1] [param2] [...] }}"

For example faker.lorem.sentence:

# generate a sentence that contains from 10 to 15 words
property: "{{ faker.lorem.sentence 10 5 }}"

The list of predefined datasets:

Please note: All methods are described in C# language. All examples are in yaml + scriban. Dataset and method names are in snake_case.

Random

number

Definition:

/// <summary>
/// Get an int from min to max.
/// </summary>
/// <param name="min">Lower bound, inclusive</param>
/// <param name="max">Upper bound, inclusive</param>
int faker.random.number(int min = 0, int max = Int32.MaxValue)

Example:

randomNumber: "{{ faker.random.number }}"
outdoorTemperature: "{{ faker.random.number (-10) 35 }}"
indoorTemperature: "{{ faker.random.number 16 28 }}"

digits

/// <summary>
/// Get a random sequence of digits.
/// </summary>
/// <param name="count">How many</param>
/// <param name="minDigit">minimum digit, inclusive</param>
/// <param name="maxDigit">maximum digit, inclusive</param>
int[] faker.random.digits(int count, int minDigit = 0, int maxDigit = 9)

even

/// <summary>
/// Returns a random even number. If the range does not contain any even numbers, an ArgumentException is thrown.
/// </summary>
/// <param name="min">Lower bound, inclusive</param>
/// <param name="max">Upper bound, inclusive</param>
/// <exception cref="ArgumentException">Thrown if it is impossible to select an odd number satisfying the specified range.</exception>
int faker.random.even(int min = 0, int max = Int32.MaxValue)

odd

/// <summary>
/// Returns a random odd number. If the range does not contain any odd numbers, an ArgumentException is thrown.
/// </summary>
/// <param name="min">Lower bound, inclusive</param>
/// <param name="max">Upper bound, inclusive</param>
/// <exception cref="ArgumentException">Thrown if it is impossible to select an odd number satisfying the specified range.</exception>
int faker.random.odd(int min = 0, int max = Int32.MaxValue)

double

/// <summary>
/// Get a random double, between 0.0 and 1.0.
/// </summary>
/// <param name="min">Minimum, default 0.0</param>
/// <param name="max">Maximum, default 1.0</param>
double faker.random.double(double min = 0.0d, double max = 1.0d)

decimal

/// <summary>
/// Get a random decimal, between 0.0 and 1.0.
/// </summary>
/// <param name="min">Minimum, default 0.0</param>
/// <param name="max">Maximum, default 1.0</param>
decimal faker.random.decimal(decimal min = 0.0m, decimal max = 1.0m)

float

/// <summary>
/// Get a random float, between 0.0 and 1.0.
/// </summary>
/// <param name="min">Minimum, default 0.0</param>
/// <param name="max">Maximum, default 1.0</param>
float faker.random.float(float min = 0.0f, float max = 1.0f)

byte

/// <summary>
/// Generate a random byte between 0 and 255.
/// </summary>
/// <param name="min">Min value, default byte.MinValue 0</param>
/// <param name="max">Max value, default byte.MaxValue 255</param>
byte faker.random.byte(byte min = byte.MinValue, byte max = byte.MaxValue)

bytes

/// <summary>
/// Get a random sequence of bytes.
/// </summary>
/// <param name="count">The size of the byte array</param>
byte[] faker.random.bytes(int count)

long

/// <summary>
/// Generate a random long between MinValue and MaxValue.
/// </summary>
/// <param name="min">Min value, default long.MinValue</param>
/// <param name="max">Max value, default long.MaxValue</param>
long faker.random.long(long min = long.MinValue, long max = long.MaxValue)

string

/// <summary>
/// Get a string of characters between minLength and maxLength.
/// Note: This method can return ill-formed UTF16 Unicode strings with unpaired surrogates.
/// Use utf16_string for technically valid Unicode.
/// </summary>
/// <param name="minLength">Lower-bound string length. Inclusive.</param>
/// <param name="maxLength">Upper-bound string length. Inclusive.</param>
/// <param name="minChar">Min character value, default char.MinValue</param>
/// <param name="maxChar">Max character value, default char.MaxValue</param>
string faker.random.string(int minLength, int maxLength, char minChar = char.MinValue, char maxChar = char.MaxValue)

string2

/// <summary>
/// Get a string of characters with a specific length drawing characters from chars.
/// The returned string may contain repeating characters from the chars string.
/// </summary>
/// <param name="minLength">The minimum length of the string to return.</param>
/// <param name="maxLength">The maximum length of the string to return.</param>
/// <param name="chars">The pool of characters to draw from. The returned string may contain repeat characters from the pool.</param>
string faker.random.string2(int minLength, int maxLength, string chars = "abcdefghijklmnopqrstuvwxyz")

utf16_string

/// <summary>
/// Get a string of valid UTF16 Unicode characters.
/// This method returns a string where each character IsLetterOrDigit() is true.
/// </summary>
/// <param name="minLength">The minimum length of the string to return.</param>
/// <param name="maxLength">The maximum length of the string to return.</param>
/// <param name="excludeSurrogates">Excludes surrogate pairs from the returned string.</param>
string faker.random.utf16_string(int minLength = 40, int maxLength = 80, bool excludeSurrogates = false)

hash

/// <summary>
/// Return a random hex hash. Default 40 characters, aka SHA-1.
/// </summary>
/// <param name="length">The length of the hash string. Default, 40 characters, aka SHA-1.</param>
/// <param name="upperCase">Returns the hex string with uppercase characters.</param>
string faker.random.hash(int length = 40, bool upperCase = false)

bool

/// <summary>
/// Get a random boolean.
/// </summary>
/// <param name="weight">The probability of true. Ranges from 0 to 1.</param>
bool faker.random.bool(float weight)

replace_numbers

/// <summary>
/// Replaces symbols with numbers.
/// IE: ### -> 283
/// </summary>
/// <param name="format">The string format</param>
/// <param name="symbol">The symbol to search for in format that will be replaced with a number</param>
string faker.random.replace_numbers(string format, char symbol = '#')

clamp_string

/// <summary>
/// Clamps the length of a string between min and max characters.
/// If the string is below the minimum, the string is appended with random characters up to the minimum length.
/// If the string is over the maximum, the string is truncated at maximum characters; additionally, if the result string ends with
/// whitespace, it is replaced with a random characters.
/// </summary>
string faker.random.clamp_string(string str, int? min = null, int? max = null)

word

/// <summary>
/// Returns a single word or phrase in English.
/// </summary>
string faker.random.word()

words

/// <summary>
/// Gets some random words and phrases in English.
/// </summary>
/// <param name="count">Number of times to call Word()</param>
string faker.random.words(int? count = null)

words_array

/// <summary>
/// Get a range of words in an array (English).
/// </summary>
/// <param name="min">Minimum word count.</param>
/// <param name="max">Maximum word count.</param>
string[] faker.random.words_array(int min, int max)

guid

/// <summary>
/// Get a random GUID.
/// </summary>
Guid faker.random.guid()

uuid

/// <summary>
/// Get a random GUID. Alias for Randomizer.Guid().
/// </summary>
Guid faker.random.uuid()

random_locale

/// <summary>
/// Returns a random locale.
/// </summary>
string faker.random.random_locale()

alpha_numeric

/// <summary>
/// Returns a random set of alpha numeric characters 0-9, a-z.
/// </summary>
string faker.random.alpha_numeric(int length)

hexadecimal

/// <summary>
/// Generates a random hexadecimal string.
/// </summary>
string faker.random.hexadecimal(int length = 1, string prefix = "0x")

Address

zip_code

/// <summary>
/// Get a zipcode.
/// </summary>
/// <param name="format">
/// If a format is provided it will fill the format with letters and numbers.
/// Example "???? ##" can become "QYTE 78".
/// </param>
/// <returns>A random zipcode.</returns>
string faker.address.zip_code(string format = null)

city

/// <summary>
/// Get a city name.
/// </summary>
/// <returns>A random city name.</returns>
string faker.address.city()

street_address

/// <summary>
/// Get a street address.
/// </summary>
/// <param name="useFullAddress">If true, the returned value will also include a SecondaryAddress.</param>
/// <returns>A random street address.</returns>
string faker.address.street_address(bool useFullAddress = false)

city_prefix

/// <summary>
/// Get a city prefix.
/// </summary>
/// <returns>A random city prefix.</returns>
string faker.address.city_prefix()

city_suffix

/// <summary>
/// Get a city suffix.
/// </summary>
/// <returns>A random city suffix.</returns>
string faker.address.city_suffix()

street_name

/// <summary>
/// Get a street name.
/// </summary>
/// <returns>A random street name.</returns>
string faker.address.street_name()

building_number

/// <summary>
/// Get a building number.
/// </summary>
/// <returns>A random building number.</returns>
string faker.address.building_number()

secondary_address

/// <summary>
/// Get a secondary address like 'Apt. 2' or 'Suite 321'.
/// </summary>
/// <returns>A random secondary address.</returns>
string faker.address.secondary_address()

county

/// <summary>
/// Get a county.
/// </summary>
/// <returns>A random county.</returns>
string faker.address.county()

country

/// <summary>
/// Get a country.
/// </summary>
/// <returns>A random country.</returns>
string faker.address.country()

full_address

/// <summary>
/// Get a full address like Street, City, Country.
/// </summary>
/// <returns>A random full address.</returns>
string faker.address.full_address()

country_code

/// <summary>
/// Get a random ISO 3166-1 country code.
/// </summary>
/// <param name="format">The format the country code should be in.</param>
/// <returns>A random country code.</returns>
string faker.address.country_code(Iso3166Format format = alpha2)

enum Iso3166Format
{
  /// <summary>
  /// Two character ISO 3166-1 format.
  /// </summary>
  alpha2 = 0x2,

  /// <summary>
  /// Three character ISO 3166-1 format.
  /// </summary>
  alpha3
}

state

/// <summary>
/// Get a random state state.
/// </summary>
/// <returns>A random state.</returns>
string faker.address.state()

state_abbr

/// <summary>
/// Get a state abbreviation.
/// </summary>
/// <returns>An abbreviation for a random state.</returns>
string faker.address.state_abbr()

latitude

/// <summary>
/// Get a Latitude.
/// </summary>
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <returns>A random latitude value.</returns>
double faker.address.latitude(double min = -90, double max = 90)

longitude

/// <summary>
/// Get a Longitude.
/// </summary>
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <returns>A random longitude value.</returns>
double faker.address.longitude(double min = -180, double max = 180)

direction

/// <summary>
/// Generates a cardinal or ordinal direction. IE: Northwest, South, SW, E.
/// </summary>
/// <param name="useAbbreviation">When true, directions such as Northwest turn into NW.</param>
/// <returns>A random cardinal or ordinal direction.</returns>
string faker.address.direction(bool useAbbreviation = false)

cardinal_direction

/// <summary>
/// Generates a cardinal direction. IE: North, South, E, W.
/// </summary>
/// <param name="useAbbreviation">When true, directions such as West turn into W.</param>
/// <returns>A random cardinal direction</returns>
string faker.address.cardinal_direction(bool useAbbreviation = false)

ordinal_direction

/// <summary>
/// Generates an ordinal direction. IE: Northwest, Southeast, SW, NE.
/// </summary>
/// <param name="useAbbreviation">When true, directions such as Northwest turn into NW.</param>
/// <returns>A random ordinal direction.</returns>
string faker.address.ordinal_direction(bool useAbbreviation = false)

Company

company_suffix

/// <summary>
/// Get a company suffix. "Inc" and "LLC" etc.
/// </summary>
/// <returns>A random company suffix.</returns>
string faker.company.company_suffix()

company_name

/// <summary>
/// Get a company name.
/// </summary>
/// <param name="formatIndex">0: name + suffix, 1: name-name, 2: name, name and name."</param>
/// <returns>A random company name.</returns>
string faker.company.company_name(int? formatIndex = null)

catch_phrase

/// <summary>
/// Get a company catch phrase.
/// </summary>
/// <returns>A random company catch phrase.</returns>
string faker.company.catch_phrase()

bs

/// <summary>
/// Get a company BS phrase.
/// </summary>
/// <returns>A random company BS phrase.</returns>
string faker.company.bs()

Date

For HTTP JSON payloads we convert a datetime object to a textual representation using the date.format which default to %F (ISO 8601 date %Y-%m-%d).

You can override the format using any of the formats supported by scriban:

- method: greet.Greeter/SayHello
  response:
    header:
      Expires: "{{ date.now | date.to_string '%a, %d %b %Y %T %Z' }}"

past

/// <summary>
/// Get a DateTime in the past between refDate and yearsToGoBack.
/// </summary>
/// <param name="yearsToGoBack">Years to go back from refDate. Default is 1 year.</param>
/// <param name="refDate">The date to start calculations. Default is DateTime.Now.</param>
DateTime faker.date.past(int yearsToGoBack = 1, DateTime? refDate = null)

soon

/// <summary>
/// Get a DateTime that will happen soon.
/// </summary>
/// <param name="days">A date no more than days ahead.</param>
/// <param name="refDate">The date to start calculations. Default is DateTimeOffset.Now.</param>
DateTime faker.date.soon(int days = 1, DateTime? refDate = null)

future

/// <summary>
/// Get a DateTime in the future between refDate and yearsToGoForward.
/// </summary>
/// <param name="yearsToGoForward">Years to go forward from refDate. Default is 1 year.</param>
/// <param name="refDate">The date to start calculations. Default is DateTime.Now</param>
DateTime faker.date.future(int yearsToGoForward = 1, DateTime? refDate = null)

recent

/// <summary>
/// Get a random DateTime within the last few days.
/// </summary>
/// <param name="days">Number of days to go back.</param>
/// <param name="refDate">The date to start calculations. Default is DateTime.Now.</param>
DateTime faker.date.recent(int days = 1, DateTime? refDate = null)

month

/// <summary>
/// Get a random month.
/// </summary>
string faker.date.month(bool abbreviation = false, bool useContext = false)

weekday

/// <summary>
/// Get a random weekday.
/// </summary>
string faker.date.weekday(bool abbreviation = false, bool useContext = false)

time_zone_string

/// <summary>
/// Get a timezone string. Eg: America/Los_Angeles
/// </summary>
string faker.date.time_zone_string()

Finance

account

/// <summary>
/// Get an account number. Default length is 8 digits.
/// </summary>
/// <param name="length">The length of the account number.</param>
string faker.finance.account(int length = 8)

account_name

/// <summary>
/// Get an account name. Like "savings", "checking", "Home Loan" etc..
/// </summary>
string faker.finance.account_name()

amount

/// <summary>
/// Get a random amount. Default 0 - 1000.
/// </summary>
/// <param name="min">Min value. Default 0.</param>
/// <param name="max">Max value. Default 1000.</param>
/// <param name="decimals">Decimal places. Default 2.</param>
decimal faker.finance.amount(decimal min = 0, decimal max = 1000, int decimals = 2)

transaction_type

/// <summary>
/// Get a transaction type: "deposit", "withdrawal", "payment", or "invoice".
/// </summary>
string faker.finance.transaction_type()

currency_code

/// <summary>
/// Get a random currency code.
/// </summary>
string faker.finance.currency_code(bool includeFundCodes = false)

currency_symbol

/// <summary>
/// Get a random currency symbol.
/// </summary>
string faker.finance.currency_symbol(bool includeFundCodes = false)

credit_card_number

/// <summary>
/// Generate a random credit card number with valid Luhn checksum.
/// </summary>
/// <param name="provider">The type of credit card to generate (ie: American Express, Discover, etc.). Passing null, a random card provider will be chosen.</param>
string faker.finance.credit_card_number(CardType provider = null)

credit_card_cvv

/// <summary>
/// Generate a credit card CVV.
/// </summary>
string faker.finance.credit_card_cvv()

bitcoin_address

/// <summary>
/// Generates a random Bitcoin address.
/// </summary>
string faker.finance.bitcoin_address()

ethereum_address

/// <summary>
/// Generate a random Ethereum address.
/// </summary>
string faker.finance.ethereum_address()

litecoin_address

/// <summary>
/// Generate a random Litecoin address.
/// </summary>
string faker.finance.litecoin_address()

bic

/// <summary>
/// Generates Bank Identifier Code (BIC) code.
/// </summary>
string faker.finance.bic()

iban

/// <summary>
/// Generates an International Bank Account Number (IBAN).
/// </summary>
/// <param name="formatted">Formatted IBAN containing spaces.</param>
/// <param name="countryCode">A two letter ISO3166 country code. Throws an exception if the country code is not found or is an invalid length.</param>
/// <exception cref="KeyNotFoundException">An exception is thrown if the ISO3166 country code is not found.</exception>
string faker.finance.iban(bool formatted = false, string countryCode = null)

Hacker

abbreviation

/// <summary>
/// Returns an abbreviation.
/// </summary>
/// <returns>A random abbreviation.</returns>
string faker.hacker.abbreviation()

adjective

/// <summary>
/// Returns a adjective.
/// </summary>
/// <returns>A random adjective.</returns>
string faker.hacker.adjective()

noun

/// <summary>
/// Returns a noun.
/// </summary>
/// <returns>A random noun.</returns>
string faker.hacker.noun()

verb

/// <summary>
/// Returns a verb.
/// </summary>
/// <returns>A random verb.</returns>
string faker.hacker.verb()

ing_verb

/// <summary>
/// Returns a verb ending with -ing.
/// </summary>
/// <returns>A random -ing verb.</returns>
string faker.hacker.ing_verb()

phrase

/// <summary>
/// Returns a phrase.
/// </summary>
/// <returns>A random phrase.</returns>
string faker.hacker.phrase()

Image

data_uri

/// <summary>
/// Get a SVG data URI image with a specific width and height.
/// </summary>
/// <param name="width">Width of the image.</param>
/// <param name="height">Height of the image.</param>
/// <param name="htmlColor">An html color in named format 'grey', RGB format 'rgb(r,g,b)', or hex format '#888888'.</param>
string faker.image.data_uri(int width, int height, string htmlColor = "grey")

place_img_url

/// <summary>
/// Get an image from the https://placeimg.com service.
/// </summary>
/// <param name="width">Width of the image.</param>
/// <param name="height">Height of the image.</param>
/// <param name="category">Category of the image.</param>
/// <param name="filter">The filter to apply to the image.</param>
/// <returns></returns>
string faker.image.place_img_url(
    int width = 640, int height = 480,
    string category = "any", // "animals", "arch", "nature", "people", "tech", "any"
    PlaceImgFilter? filter = null);

enum PlaceImgFilter
{
  grayscale,
  sepia
}

picsum_url

/// <summary>
/// Get an image from the https://picsum.photos service.
/// </summary>
/// <param name="width">Width of the image.</param>
/// <param name="height">Height of the image.</param>
/// <param name="grayscale">Grayscale (no color) image.</param>
/// <param name="blur">Blurry image.</param>
/// <param name="imageId">Optional Image ID found here https://picsum.photos/images</param>
string faker.image.picsum_url(int width = 640, int height = 480, bool grayscale = false, bool blur = false, int? imageId = null )

lorem_flickr_url

/// <summary>
/// Get an image from https://loremflickr.com service.
/// </summary>
/// <param name="keywords">Space or comma delimited list of keywords you want the picture to contain. IE: "cat, dog" for images with cats and dogs.</param>
/// <param name="width">The image width.</param>
/// <param name="height">The image height.</param>
/// <param name="grascale">Grayscale the image.</param>
/// <param name="matchAllKeywords">True tries to match an image with all specified keywords. False tries to match an image with any specified keyword.</param>
/// <param name="lockId">Deterministic image id. By default, this method generates URLs with image lock ids.
/// So, if a random seed is set, repeat runs of this method will generate the same lock id sequence
/// for images. If you want explicit control over the lock id, you can pass it as a parameter here.
/// Additionally, if you don't want any lock ids, pass -1 for this parameter this method will generate
/// a URL that will result in a new random image every time the HTTP URL is hit.
/// </param>
string faker.image.lorem_flickr_url(
    int width = 320, int height = 240,
    string keywords = null,
    bool grascale = false,
    bool matchAllKeywords = false, int? lockId = null)

lorem_pixel_url

/// <summary>
/// Creates an image URL with http://lorempixel.com. Note: This service is slow. Consider using PicsumUrl() as a faster alternative.
/// </summary>
string faker.image.lorem_pixel_url(
  string category = "random", // "abstract", "animals", "business", "cats", "city", "food", "nightlife", "fashion", "people", "nature", "sports", "technics", "transport", "random"
  int width = 640, int height = 480, bool randomize = false, bool https = false);

placeholder_url

/// <summary>
/// Get an image from https://placeholder.com service.
/// </summary>
/// <param name="width">Width of the image.</param>
/// <param name="height">Height of the image.</param>
/// <param name="text"></param>
/// <param name="format">Image format. Supported values: 'jpg', 'jpeg', 'png', 'gif', 'webp'.</param>
/// <param name="backColor">HTML color code for the background color.</param>
/// <param name="textColor">HTML color code for the foreground (text) color.</param>
string faker.image.placeholder_url(int width, int height, string text = null, string backColor = "cccccc", string textColor = "9c9c9c", string format = "png")

Internet

avatar

/// <summary>
/// Generates a legit Internet URL avatar from twitter accounts.
/// </summary>
/// <returns>A string containing a URL avatar from twitter accounts.</returns>
string faker.internet.avatar()

email

/// <summary>
/// Generates an email address.
/// </summary>
/// <param name="firstName">Always use this first name.</param>
/// <param name="lastName">Sometimes used depending on randomness. See 'UserName'.</param>
/// <param name="provider">Always use the provider.</param>
/// <param name="uniqueSuffix">This parameter is appended to
/// the email account just before the @ symbol. This is useful for situations
/// where you might have a unique email constraint in your database or application.
/// Passing var f = new Faker(); f.UniqueIndex is a good choice. Or you can supply
/// your own unique changing suffix too like Guid.NewGuid; just be sure to change the
/// uniqueSuffix value each time before calling this method
/// to ensure that email accounts that are generated are totally unique.</param>
/// <returns>An email address</returns>
string faker.internet.email(string firstName = null, string lastName = null, string provider = null, string uniqueSuffix = null)

example_email

/// <summary>
/// Generates an example email with @example.com.
/// </summary>
/// <param name="firstName">Optional: first name of the user.</param>
/// <param name="lastName">Optional: last name of the user.</param>
/// <returns>An example email ending with @example.com.</returns>
string faker.internet.example_email(string firstName = null, string lastName = null)

user_name

/// <summary>
/// Generates user names.
/// </summary>
/// <param name="firstName">First name is always part of the returned user name.</param>
/// <param name="lastName">Last name may or may not be used.</param>
/// <returns>A random user name.</returns>
string faker.internet.user_name(string firstName = null, string lastName = null)

user_name_unicode

/// <summary>
/// Generates a user name preserving Unicode characters.
/// </summary>
/// <param name="firstName">First name is always part of the returned user name.</param>
/// <param name="lastName">Last name may or may not be used.</param>
string faker.internet.user_name_unicode(string firstName = null, string lastName = null)

domain_name

/// <summary>
/// Generates a random domain name.
/// </summary>
/// <returns>A random domain name.</returns>
string faker.internet.domain_name()

domain_word

/// <summary>
/// Generates a domain word used for domain names.
/// </summary>
/// <returns>A random domain word.</returns>
string faker.internet.domain_word()

domain_suffix

/// <summary>
/// Generates a domain name suffix like .com, .net, .org
/// </summary>
/// <returns>A random domain suffix.</returns>
string faker.internet.domain_suffix()

ip

/// <summary>
/// Gets a random IPv4 address string.
/// </summary>
/// <returns>A random IPv4 address.</returns>
string faker.internet.ip()

port

/// <summary>
/// Generates a random port number.
/// </summary>
/// <returns>A random port number</returns>
int faker.internet.port()

ipv6

/// <summary>
/// Generates a random IPv6 address string.
/// </summary>
/// <returns>A random IPv6 address.</returns>
string faker.internet.ipv6()

user_agent

/// <summary>
/// Generates a random user agent.
/// </summary>
/// <returns>A random user agent.</returns>
string faker.internet.user_agent()

password

/// <summary>
/// Generates a random password.
/// </summary>
/// <param name="length">Length of the password.</param>
/// <param name="memorable">A memorable password (ie: all lower case).</param>
/// <param name="regexPattern">Regex pattern that the password should follow.</param>
/// <param name="prefix">Password prefix.</param>
/// <returns>A random password.</returns>
string faker.internet.password(int length = 10, bool memorable = false, string regexPattern = "\w", string prefix = "")

color

/// <summary>
/// Gets a random aesthetically pleasing color near the base RGB. See [here](http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette).
/// </summary>
/// <param name="baseRed">Red base color</param>
/// <param name="baseGreen">Green base color</param>
/// <param name="baseBlue">Blue base color</param>
/// <param name="grayscale">Output a gray scale color</param>
/// <param name="format">The color format</param>
/// <returns>A random color.</returns>
string faker.internet.color(byte baseRed = 0, byte baseGreen = 0, byte baseBlue = 0, bool grayscale = false, ColorFormat format = ColorFormat.Hex)

protocol

/// <summary>
/// Returns a random protocol. HTTP or HTTPS.
/// </summary>
/// <returns>A random protocol.</returns>
string faker.internet.protocol()

url

/// <summary>
/// Generates a random URL.
/// </summary>
/// <returns>A random URL.</returns>
string faker.internet.url()

url_with_path

/// <summary>
/// Get an absolute URL with random path.
/// </summary>
/// <param name="protocol">Protocol part of the URL, random if null</param>
/// <param name="domain">Domain part of the URL, random if null</param>
/// <param name="fileExt">The file extension to use in the path, directory if null</param>
/// <returns>An URL with a random path.</returns>
string faker.internet.url_with_path(string protocol = null, string domain = null, string fileExt = null)

url_rooted_path

/// <summary>
/// Get a rooted URL path like: /foo/bar. Optionally with file extension.
/// </summary>
/// <param name="fileExt">Optional: The file extension to use. If fileExt is null, then a rooted URL directory is returned.</param>
/// <returns>Returns a rooted URL path like: /foo/bar; optionally with a file extension.</returns>
string faker.internet.url_rooted_path(string fileExt = null)

Lorem

word

/// <summary>
/// Get a random lorem word.
/// </summary>
string faker.lorem.word()

words

/// <summary>
/// Get an array of random lorem words.
/// </summary>
/// <param name="num">The number of random lorem words to return.</param>
string[] faker.lorem.words(int num = 3)

letter

/// <summary>
/// Get a character letter.
/// </summary>
/// <param name="num">The number of characters to return.</param>
string faker.lorem.letter(int num = 1)

sentence

/// <summary>
/// Get a random sentence of specific number of words. 
/// </summary>
/// <param name="wordCount">Get a sentence with wordCount words. Defaults between 3 and 10.</param>
/// <param name="range">Add anywhere between 0 to 'range' additional words to wordCount. Default is 0.</param>
string faker.lorem.sentence(int? wordCount = null, int? range = 0)

paragraph

/// <summary>
/// Get a paragraph.
/// </summary>
/// <param name="min">The minimum number of sentences in the paragraph.
/// The final number of sentences returned in the paragraph is bound between [min, min + 3], inclusive.
/// If you want an exact number of sentences, use the Sentences method.</param>
string faker.lorem.paragraph(int min = 3)

paragraphs

/// <summary>
/// Get a specified number of paragraphs.
/// </summary>
/// <param name="count">Number of paragraphs.</param>
/// <param name="separator">The string to separate paragraphs.</param>
string faker.lorem.paragraphs(int count = 3, string separator = "

")

text

/// <summary>
/// Get random text on a random lorem methods.
/// </summary>
string faker.lorem.text()

lines

/// <summary>
/// Get lines of lorem.
/// </summary>
/// <param name="lineCount">The amount of lines to generate. Defaults between 1 and 5.</param>
/// <param name="separator">The string to separate the lines.</param>
string faker.lorem.lines(int? lineCount = null, string separator = "
")

slug

/// <summary>
/// Slugify lorem words.
/// </summary>
/// <param name="wordcount">The amount of words to slugify.</param>
string faker.lorem.slug(int wordcount = 3)

Music

genre

/// <summary>
/// Get a music genre
/// </summary>
string faker.music.genre()

Name

Gender type

enum Gender
{
    male,
    female
}

first_name

/// <summary>
/// Get a first name. Getting a gender specific name is only supported on locales that support it.
/// </summary>
/// <param name="gender">For locale's that support Gender naming.</param>
string faker.name.first_name(Gender? gender = null)

last_name

/// <summary>
/// Get a last name. Getting a gender specific name is only supported on locales that support it.
/// </summary>
/// <param name="gender">For locale's that support Gender naming.</param>
string faker.name.last_name(Gender? gender = null)

full_name

/// <summary>
/// Get a full name, concatenation of calling FirstName and LastName.
/// </summary>
/// <param name="gender">Gender of the name if supported by the locale.</param>
string faker.name.full_name(Gender? gender = null)

prefix

/// <summary>
/// Gets a random prefix for a name.
/// </summary>
string faker.name.prefix(Gender? gender = null)

suffix

/// <summary>
/// Gets a random suffix for a name.
/// </summary>
string faker.name.suffix()

job_descriptor

/// <summary>
/// Get a job description.
/// </summary>
string faker.name.job_descriptor()

job_area

/// <summary>
/// Get a job area expertise.
/// </summary>
string faker.name.job_area()

job_title

/// <summary>
/// Gets a random job title.
/// </summary>
string faker.name.job_title()

job_type

/// <summary>
/// Get a type of job.
/// </summary>
string faker.name.job_type()

Phone

phone_number

/// <summary>
/// Get a phone number.
/// </summary>
/// <param name="format">
/// Format of phone number in any format.
/// Replaces # characters with numbers. IE: '###-###-####' or '(###) ###-####'.
/// </param>
/// <returns>A random phone number.</returns>
string faker.phone.phone_number(string format = null)

phone_number_format

/// <summary>
/// Gets a phone number based on the locale's phone_number.formats[] array index.
/// </summary>
/// <param name="phoneFormatsArrayIndex">The array index as defined in the locale's phone_number.formats[] array.</param>
/// <returns>A random phone number.</returns>
string faker.phone.phone_number_format(int phoneFormatsArrayIndex = 0)

System

file_name

/// <summary>
/// Get a random file name.
/// </summary>
/// <param name="ext">
/// The extension the file name will have.
/// If null is provided, a random extension will be picked.
/// </param>
/// <returns>
/// A random file name with the given ext
/// or a random extension
/// </returns>
string faker.system.file_name(string ext = null)

directory_path

/// <summary>
/// Get a random directory path (Unix).
/// </summary>
/// <returns>
/// A random Unix directory path.
/// </returns>
string faker.system.directory_path()

file_path

/// <summary>
/// Get a random file path (Unix).
/// </summary>
/// <returns>
/// A random Unix file path.
/// </returns>
string faker.system.file_path()

common_file_name

/// <summary>
/// Generates a random file name with a common file extension.
/// Extension can be overwritten with ext.
/// </summary>
/// <param name="ext">
/// The extensions to be used for a file name.
/// </param>
/// <returns>
/// A random file name with a common extension or ext.
/// </returns>
string faker.system.common_file_name(string ext = null)

mime_type

/// <summary>
/// Get a random mime type.
/// </summary>
/// <returns>
/// A random mime type.
/// </returns>
string faker.system.mime_type()

common_file_type

/// <summary>
/// Returns a commonly used file type.
/// </summary>
/// <returns>
/// A commonly used file type.
/// </returns>
string faker.system.common_file_type()

common_file_ext

/// <summary>
/// Returns a commonly used file extension.
/// </summary>
/// <returns>
/// A commonly used file extension.
/// </returns>
string faker.system.common_file_ext()

file_type

/// <summary>
/// Returns any file type available as mime-type.
/// </summary>
/// <returns>
/// Any file type available as mime-type.
/// </returns>
string faker.system.file_type()

file_ext

/// <summary>
/// Gets a random extension for the given mime type.
/// </summary>
/// <returns>
/// A random extension for the given mime type.
/// </returns>
string faker.system.file_ext(string mimeType = null)

semver

/// <summary>
/// Get a random semver version string.
/// </summary>
/// <returns>
/// A random semver version string.
/// </returns>
string faker.system.semver()

android_id

/// <summary>
/// Get a random GCM registration ID.
/// </summary>
/// <returns>
/// A random GCM registration ID.
/// </returns>
string faker.system.android_id()

apple_push_token

/// <summary>
/// Get a random Apple Push Token.
/// </summary>
/// <returns>
/// A random Apple Push Token.
/// </returns>
string faker.system.apple_push_token()

black_berry_pin

/// <summary>
/// Get a random BlackBerry Device PIN.
/// </summary>
/// <returns>
/// A random BlackBerry Device PIN.
/// </returns>
string faker.system.black_berry_pin()

Commerce

department

/// <summary>
/// Get a random commerce department.
/// </summary>
/// <param name="max">The maximum amount of departments</param>
/// <param name="returnMax">If true the method returns the max amount of values, otherwise the number of categories returned is between 1 and max.</param>
/// <returns>A random commerce department.</returns>
string faker.commerce.department(int max = 3, bool returnMax = false)

price

/// <summary>
/// Get a random product price.
/// There is an easier way to do this.
/// check faker.finance.amount
/// </summary>
/// <param name="min">The minimum price.</param>
/// <param name="max">The maximum price.</param>
/// <param name="decimals">How many decimals the number may include.</param>
/// <param name="symbol">The symbol in front of the price.</param>
/// <returns>A randomly generated price.</returns>
string faker.commerce.price(decimal min = 1, decimal max = 1000, int decimals = 2, string symbol = "")

categories

/// <summary>
/// Get random product categories.
/// </summary>
/// <param name="num">The amount of categories to be generated.</param>
/// <returns>A collection of random product categories.</returns>
string[] faker.commerce.categories(int num)

product_name

/// <summary>
/// Get a random product name.
/// </summary>
/// <returns>A random product name.</returns>
string faker.commerce.product_name()

color

/// <summary>
/// Get a random color.
/// </summary>
/// <returns>A random color.</returns>
string faker.commerce.color()

product

/// <summary>
/// Get a random product.
/// </summary>
/// <returns>A random product.</returns>
string faker.commerce.product()

product_adjective

/// <summary>
/// Random product adjective.
/// </summary>
/// <returns>A random product adjective.</returns>
string faker.commerce.product_adjective()

product_material

/// <summary>
/// Random product material.
/// </summary>
/// <returns>A random product material.</returns>
string faker.commerce.product_material()

product_description

/// <summary>
/// Random product description.
/// </summary>
/// <returns>A random product description.</returns>
string faker.commerce.product_description()

ean8

/// <summary>
/// Get a random EAN-8 barcode number.
/// </summary>
/// <returns>A random EAN-8 barcode number.</returns>
string faker.commerce.ean8()

ean13

/// <summary>
/// Get a random EAN-13 barcode number.
/// </summary>
/// <returns>A random EAN-13 barcode number.</returns>
string faker.commerce.ean13()

Database

column

/// <summary>
/// Generates a column name.
/// </summary>
/// <returns>A random column name.</returns>
string faker.database.column()

type

/// <summary>
/// Generates a column type.
/// </summary>
/// <returns>A random column type.</returns>
string faker.database.type()

collation

/// <summary>
/// Generates a collation.
/// </summary>
/// <returns>A random collation.</returns>
string faker.database.collation()

engine

/// <summary>
/// Generates a storage engine.
/// </summary>
/// <returns>A random storage engine.</returns>
string faker.database.engine()

Vehicle

vin

/// <summary>
/// Generate a vehicle identification number (VIN).
/// </summary>
string faker.vehicle.vin()

manufacturer

/// <summary>
/// Get a vehicle manufacture name. IE: Toyota, Ford, Porsche.
/// </summary>
string faker.vehicle.manufacturer()

model

/// <summary>
/// Get a vehicle model. IE: Camry, Civic, Accord.
/// </summary>
string faker.vehicle.model()

type

/// <summary>
/// Get a vehicle type. IE: Minivan, SUV, Sedan.
/// </summary>
string faker.vehicle.type()

fuel

/// <summary>
/// Get a vehicle fuel type. IE: Electric, Gasoline, Diesel.
/// </summary>
string faker.vehicle.fuel()
In this article
word
words
color
type