diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Common/Instancing/RandomSeedGenerator.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Common/Instancing/RandomSeedGenerator.cs index 2220c83bbd..12a53cbdac 100644 --- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Common/Instancing/RandomSeedGenerator.cs +++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Common/Instancing/RandomSeedGenerator.cs @@ -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 { @@ -20,6 +22,11 @@ public static class RandomSeedGenerator #endregion + /// + /// The seed that should be used for random number generation + /// + private static int? Seed = null; + #region Public Methods and Operators public static int GetRandomSeed() @@ -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