private static string BuildOutRandomizedTemplate(this KeyValuePair <string, string>[] keyValuePairs, FromToRange fromToRange) { var stringBuilder = new StringBuilder(); stringBuilder.AppendTemplateFragement("Start "); stringBuilder.AppendTemplateFragement(CreateRandomizedTemplateFragement(Random.Next(fromToRange.from, fromToRange.to))); foreach (var keyValuePair in keyValuePairs) { stringBuilder.AppendTemplateVariable(keyValuePair.Key); stringBuilder.AppendTemplateFragement(CreateRandomizedTemplateFragement(Random.Next(fromToRange.from, fromToRange.to))); } stringBuilder.AppendTemplateFragement(CreateRandomizedTemplateFragement(Random.Next(fromToRange.from, fromToRange.to))); stringBuilder.AppendTemplateFragement(" Completed."); return(stringBuilder.ToString()); }
public static TemplatedDocumentAndKeyValuePairs CreatTemplatedDocumentAndNameValuePairs(ushort testVariableCount, FromToRange fromToRange) { var keyValuePairs = CreateIndexedNameValuePairs(testVariableCount).ToArray(); var stringBuilder = new StringBuilder(keyValuePairs.BuildOutRandomizedTemplate(fromToRange)); var templateBuilder = stringBuilder.ToTemplateBuilder(); foreach (var keyValuePair in keyValuePairs) { templateBuilder .AddVariable(keyValuePair.Key); } return(new TemplatedDocumentAndKeyValuePairs() { KeyValuePairs = keyValuePairs, StringBuilder = stringBuilder, TemplatedDocument = templateBuilder.ToTemplatedDocument() }); }