/// <summary> /// Generates a random text, consisting of first names, last names, colors, stuffs, adjectives, verbs, and punctuation marks. /// </summary> /// <param name="minSize">minimum amount of words to generate. Text will contain 'minSize' words if 'maxSize' is omitted.</param> /// <param name="maxSize">(optional) maximum amount of words to generate.</param> /// <returns>a random text.</returns> public static string Text(int minSize, int maxSize) { maxSize = Math.Max(minSize, maxSize); int size = RandomInteger.NextInteger(minSize, maxSize); StringBuilder result = new StringBuilder(); result.Append(RandomString.Pick(_allWords)); while (result.Length < size) { String next = RandomString.Pick(_allWords); if (RandomBoolean.Chance(4, 6)) { next = " " + next.ToLower(); } else if (RandomBoolean.Chance(2, 5)) { next = RandomString.Pick(":,-") + next.ToLower(); } else if (RandomBoolean.Chance(3, 5)) { next = RandomString.Pick(":,-") + " " + next.ToLower(); } else { next = RandomString.Pick(".!?") + " " + next; } result.Append(next); } return(result.ToString()); }
/// <summary> /// Distorts a string by randomly replacing characters in it. /// </summary> /// <param name="value">a string to distort.</param> /// <returns>a distored string.</returns> public static string Distort(string value) { value = value.ToLower(); if (RandomBoolean.Chance(1, 5)) { value = value.Substring(0, 1).ToUpper() + value.Substring(1); } if (RandomBoolean.Chance(1, 3)) { value = value + Pick(_symbols); } return(value); }
/// <summary> /// Generates a random person's name which has the following structure /// optional prefix - first name - second name - optional suffix /// </summary> /// <returns>a random name.</returns> public static string Name() { StringBuilder result = new StringBuilder(); if (RandomBoolean.Chance(3, 5)) { result.Append(RandomString.Pick(_namePrefixes)).Append(" "); } result.Append(RandomString.Pick(_firstNames)) .Append(" ") .Append(RandomString.Pick(_lastNames)); if (RandomBoolean.Chance(5, 10)) { result.Append(" ").Append(RandomString.Pick(_nameSuffixes)); } return(result.ToString()); }