using CoviDok.data; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace CoviDok.BLL { public class Tools { private static Random random = new Random(); public static string RandomString(int length) { const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; return new string(Enumerable.Repeat(chars, length) .Select(s => s[random.Next(s.Length)]).ToArray()); } static T RandomEnumValue() { var v = Enum.GetValues(typeof(T)); return (T)v.GetValue(random.Next(v.Length)); } public static Case MockCase(Dictionary filters) { Case c = new Case { Id = RandomString(8) }; if (filters.ContainsKey("DoctorID")) { c.DoctorID = filters["DoctorID"]; } else { c.DoctorID = Tools.RandomString(10); } if (filters.ContainsKey("ParentID")) { c.ParentID = filters["ParentID"]; } else { c.ParentID = Tools.RandomString(10); } if (filters.ContainsKey("ChildID")) { c.ChildID = filters["ChildID"]; } else { c.ChildID = Tools.RandomString(10); } if (filters.ContainsKey("CaseStatus")) { c.ChildID = filters["CaseStatus"]; } else { c.ChildID = RandomEnumValue().ToString(); } int msgDb = random.Next(10); for (int i = 0; i < msgDb; i++) { Update u = new Update { Content = RandomString(55), Sender = RandomString(13), Id = RandomString(8) }; c.updates.Add(u); } return c; } } }