Skip to content

Commit

Permalink
Use Random.Shared (#25021)
Browse files Browse the repository at this point in the history
  • Loading branch information
martincostello committed Jun 5, 2021
1 parent e7c0b9d commit 92bae0a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3644,7 +3644,7 @@ public virtual Task Random_next_is_not_funcletized_1(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Order>().Where(o => o.OrderID < (new Random().Next() - 2147483647)));
ss => ss.Set<Order>().Where(o => o.OrderID < (Random.Shared.Next() - 2147483647)));
}
[ConditionalTheory]
Expand All @@ -3653,7 +3653,7 @@ public virtual Task Random_next_is_not_funcletized_2(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Order>().Where(o => o.OrderID > new Random().Next(5)),
ss => ss.Set<Order>().Where(o => o.OrderID > Random.Shared.Next(5)),
entryCount: 830);
}
Expand All @@ -3663,7 +3663,7 @@ public virtual Task Random_next_is_not_funcletized_3(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Order>().Where(o => o.OrderID > new Random().Next(0, 10)),
ss => ss.Set<Order>().Where(o => o.OrderID > Random.Shared.Next(0, 10)),
entryCount: 830);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private static void AddExpectedFailure(string testName, string expectedException

public void Execute<TElement>(IQueryable<TElement> query, DbContext context, string testMethodName)
{
var seed = ProceduralQueryExpressionGenerator.Seed ?? new Random().Next();
var seed = ProceduralQueryExpressionGenerator.Seed ?? Random.Shared.Next();
var random = new Random(seed);
var depth = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public static string CreateConnectionString(string name, string fileName = null,
{
var builder = new SqlConnectionStringBuilder(TestEnvironment.DefaultConnection)
{
MultipleActiveResultSets = multipleActiveResultSets ?? new Random().Next(0, 2) == 1, InitialCatalog = name
MultipleActiveResultSets = multipleActiveResultSets ?? Random.Shared.Next(0, 2) == 1, InitialCatalog = name
};
if (fileName != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public ListElement(int i)
NullableInt = i;
String = i.ToString();
XNode = new NotXText(i.ToString());
Random = new Random();
Random = Random.Shared;
ByteArray = new[] { (byte)i, (byte)i, (byte)i, (byte)i };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public ListElement(int i)
Int = i;
NullableInt = i;
String = i.ToString();
Random = new Random();
Random = Random.Shared;
ByteArray = new[] { (byte)i, (byte)i, (byte)i, (byte)i };
}

Expand Down

0 comments on commit 92bae0a

Please sign in to comment.