public static string GetRandomStringWithoutSpaces(int length, FastRandom rand) { StringBuilder strBuilder = new StringBuilder(length); for (int i = 0; i < length; i++) { strBuilder.Append(GetRandomCharWithoutSpace(rand)); } return strBuilder.ToString(); }
public static char GetRandomCharWithoutSpace(FastRandom rand) { int value = rand.Next(0, 95); switch (value) { case 0: return '\t'; case 1: return '\n'; default: return (char)(value + 31); } }
private static char GetRandomChar(FastRandom rand) { int value = rand.Next(0, 96); switch (value) { case 0: return '\t'; case 1: return '\n'; default: return (char)(value + 30); } }
private static char GetRandomPrintableCharExceptUpperCase(FastRandom rand) { int value = rand.Next(0, 68) + 32; if (value < 65) return (char)value; return (char)(value + 26); }
public static string GetRandomStringWithOnlyPrintableCharactersWithoutUpperCaseCharacters(int length, FastRandom rand) { StringBuilder strBuilder = new StringBuilder(length); for (int i = 0; i < length; i++) { strBuilder.Append(GetRandomPrintableCharExceptUpperCase(rand)); } return strBuilder.ToString(); }
public static IEnumerable<string> GetRandomStringsWithoutSpaces(int n, int minLength, int maxLength, FastRandom rand) { for (int i = 0; i < n; i++) { yield return StringValueGenerator.GetRandomStringWithoutSpaces(rand.Next(minLength, maxLength), rand); } }
private static char GetRandomLowerCaseChar(FastRandom rand) { int value = rand.Next(0, 25); return (char)(value + 97); }
public static string GetRandomLowerCaseString(int length, FastRandom rand) { StringBuilder strBuilder = new StringBuilder(length); for (int i = 0; i < length; i++) { strBuilder.Append(GetRandomLowerCaseChar(rand)); } return strBuilder.ToString(); }