/// <summary> /// Returns a random string containing <paramref name="min"/> and <paramref name="max"/> characters, /// picking random characters from <paramref name="allowedChars"/>. /// </summary> /// <param name="allowedChars">Defines the allowed characters for the string.</param> /// <param name="min">Minimum number of characters for the string. Zero is allowed. Default=1.</param> /// <param name="max">Maximum number of characters for the string.</param> public string String(string allowedChars, int min = 1, int max = 16) { var count = _randomizer.Int32(min, max); var chars = Enumerable.Range(1, count) .Select(_ => _randomizer.PickFrom(allowedChars)) .ToArray(); return(new string(chars)); }
internal IEnumerable <char> Replace(char replaceChar, Randomizer randomizer) { if (_replaceChars.ContainsKey(replaceChar)) { yield return(randomizer.PickFrom(_replaceChars[replaceChar])); } else if (_replaceFuncs.ContainsKey(replaceChar)) { var str = _replaceFuncs[replaceChar](); foreach (var ch in str) { yield return(ch); } } else { yield return(replaceChar); } }