Beispiel #1
0
        private IEnumerable <StepDef> GetStepDefinitionList(int stepDefinitionCount)
        {
            var result = new List <StepDef>();

            while (result.Count < stepDefinitionCount)
            {
                var paramList = new List <string>();
                var stepDef   = new StepDef
                {
                    Regex = string.Join(" ",
                                        LoremIpsum.GetWords(LoremIpsum.Rnd.Next(3) + 3).Select(s => ConvertToParam(s, ref paramList))),
                    DataTable = LoremIpsum.Rnd.Next(8) == 0,
                    DocString = LoremIpsum.Rnd.Next(16) == 0,
                    Keyword   = GetKeyword(result.Count)
                };
                stepDef.StepTextParams = paramList;

                var sampleText = GetStepText(stepDef, null);
                if (result.Where(sd => sd.Keyword == stepDef.Keyword).Any(sd => Regex.IsMatch(sampleText, "^" + sd.Regex + "$")))
                {
                    continue;
                }

                result.Add(stepDef);
            }
            return(result);
        }
Beispiel #2
0
        private static void AppendTable(StringBuilder content, int cellCount, string[] headers = null)
        {
            var rows = new List <string[]>();

            headers = headers ?? LoremIpsum.GetUniqueWords(cellCount);
            rows.Add(headers);
            for (int i = 0; i < 4; i++)
            {
                rows.Add(LoremIpsum.GetWords(cellCount));
            }

            var cellWiths = Enumerable.Range(0, cellCount)
                            .Select(i => rows.Max(r => r[i].Length)).ToArray();

            foreach (var row in rows)
            {
                content.Append("    | ");
                for (int i = 0; i < cellCount; i++)
                {
                    content.Append(row[i].PadRight(cellWiths[i]));
                    content.Append(" | ");
                }
                content.AppendLine();
            }
        }