Skip to content

Commit

Permalink
added logging of the seed used for random number generation
Browse files Browse the repository at this point in the history
  • Loading branch information
corranrogue9 committed May 3, 2022
1 parent 03bf038 commit 8388bee
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
//------------------------------------------------------------------------------

using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Security;
using System.Threading;

namespace Microsoft.Test.E2E.AspNet.OData.Common.Instancing
{
Expand All @@ -20,6 +22,11 @@ public static class RandomSeedGenerator

#endregion

/// <summary>
/// The seed that should be used for random number generation
/// </summary>
private static int? Seed = null;

#region Public Methods and Operators

public static int GetRandomSeed()
Expand All @@ -44,10 +51,15 @@ public static int GetRandomSeed()
{
}

// Keep the randomness per hour instead of per day.
DateTime now = DateTime.UtcNow;
int seed = (now.Year * 10000) + (now.Month * 100) + now.Day + now.Hour;
return seed;
if (Seed == null)
{
// Keep the randomness per hour instead of per day.
DateTime now = DateTime.UtcNow;
Seed = (now.Year * 10000) + (now.Month * 100) + now.Day + now.Hour;
Console.WriteLine($"Generated seed for random number generator: {Seed}");
}

return Seed.Value;
}

#endregion
Expand Down

0 comments on commit 8388bee

Please sign in to comment.