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()); }
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); }
public void TestChance() { bool value; value = RandomBoolean.Chance(5, 10); Assert.True(value || !value); value = RandomBoolean.Chance(5, 5); Assert.True(value || !value); value = RandomBoolean.Chance(0, 0); Assert.True(!value); value = RandomBoolean.Chance(-1, 0); Assert.True(!value); value = RandomBoolean.Chance(-1, -1); Assert.True(!value); }
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()); }