C#: Get a Random Name for Test Purposes

C# code to Get a Random Name for Test Purposes. Good for populating test records. Extend it for Firstnames, Surnames and job titles, etc.

C# Code Snippets

Get a Random Name for Test purposes

Good for populating test records. Extend it for Firstnames, Surnames and job titles, etc.

public static string[] Names = new string[] {
  "Tom", "Rich", "Barry",
  "Chris","Mary","Kate",
  "Mo","Dil","Eddy",
  "Pat","Peter","Matt",
  "Jo","Anne","Don",
  "Sales","Eng","Training",
  "Tommy","Team A","Team B",
  "Andy","Rachel","Les"
};

public static string GetRandomName()
{
    Random random = new Random();
    int rand = random.Next(0, YourClassName.Names.Length - 1);
    return TestTools.Names[rand];
}