You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

78 lines
2.1 KiB

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<T>()
{
var v = Enum.GetValues(typeof(T));
return (T)v.GetValue(random.Next(v.Length));
}
public static Case MockCase(Dictionary<string, string> 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<CaseStatus>().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;
}
}
}