-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomExtensionMethods.cs
33 lines (28 loc) · 1.04 KB
/
RandomExtensionMethods.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace BigRepositoryBuilder
{
public static class RandomExtensionMethods
{
public static string GenerateName(this Random random)
{
var stringCharacters = new char[40];
var availableCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
for (int i = 0; i < stringCharacters.Length; i++)
{
stringCharacters[i] = availableCharacters[random.Next(availableCharacters.Length)];
}
return new string(stringCharacters);
}
public static string GeneratePath(this Random random)
{
var availableCharacters = "0123456789abcdef";
var pathDepth = random.Next(2, 4);
var path = new List<string>();
for (int i = 0; i < pathDepth; i++)
{
var folderName = availableCharacters[random.Next(availableCharacters.Length)];
path.Add(folderName.ToString());
}
return string.Join('/', path);
}
}
}