|
1 | 1 | using FluentAssertions; |
2 | 2 | using System.Runtime.CompilerServices; |
| 3 | +using System.Security.Cryptography; |
3 | 4 | using Upsilon.Apps.PassKey.Core.Public.Enums; |
4 | 5 | using Upsilon.Apps.PassKey.Core.Public.Interfaces; |
5 | 6 | using Upsilon.Apps.PassKey.Core.Public.Utils; |
@@ -85,7 +86,14 @@ public static void ClearTestEnvironment([CallerMemberName] string username = "") |
85 | 86 |
|
86 | 87 | public static string GetUsername([CallerMemberName] string username = "") => username; |
87 | 88 |
|
88 | | - private static Random _getRandom() => new((int)DateTime.Now.Ticks); |
| 89 | + private static RandomNumberGenerator _randomNumberGenerator => RandomNumberGenerator.Create(); |
| 90 | + private static Random _getRandom() |
| 91 | + { |
| 92 | + byte[] byteSeed = new byte[4]; |
| 93 | + _randomNumberGenerator.GetBytes(byteSeed); |
| 94 | + int seed = BitConverter.ToInt32(byteSeed, 0); |
| 95 | + return new Random(seed); |
| 96 | + } |
89 | 97 |
|
90 | 98 | public static string[] GetRandomStringArray(int count = 0) |
91 | 99 | { |
@@ -125,12 +133,7 @@ public static string GetRandomString(int min = 10, int max = 0) |
125 | 133 |
|
126 | 134 | public static int GetRandomInt(int max) => GetRandomInt(0, max); |
127 | 135 |
|
128 | | - public static int GetRandomInt(int min, int max) |
129 | | - { |
130 | | - Random random = _getRandom(); |
131 | | - |
132 | | - return random.Next(min, max); |
133 | | - } |
| 136 | + public static int GetRandomInt(int min, int max) => _getRandom().Next(min, max); |
134 | 137 |
|
135 | 138 | public static void LastLogsShouldMatch(IDatabase database, string[] expectedLogs) |
136 | 139 | { |
|
0 commit comments