public static List<string> GetValues(int count, Type type = Type.All) { var values = GetValues(type); if (values.Count == count) return values; else if (values.Count > count) return values.OrderBy(x => Guid.NewGuid()).Take(count).ToList(); else { var add_count = count - values.Count; var list = values.ToList(); for (int i = 0; i < add_count; i++) { list.Add(values[Random2.Next(values.Count)]); } return list; } }
public void Console() { var maxLine = 5; IConsoleBuilder builder = new ConsoleBuilder() { MaxLine = maxLine, }; Enumerable.Range(0, 10).ToList().ForEach(x => builder.AppendLine(x.ToString() + "_" + Random2.GenerateRandomString(Random2.Next(1, x + 2)))); var str = builder.ToString(); var array = str.Split(Environment.NewLine); TestContext.Write(str); Assert.IsTrue(maxLine == array.Length); }