From 8388beeee178aad4d394c089f47224f87b3d74a7 Mon Sep 17 00:00:00 2001 From: Garrett DeBruin Date: Thu, 28 Apr 2022 08:17:45 -0700 Subject: [PATCH 1/2] added logging of the seed used for random number generation --- .../Common/Instancing/RandomSeedGenerator.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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 From a0c65b01aa45ee072c1ec4d2ce66c0305104e965 Mon Sep 17 00:00:00 2001 From: Garrett DeBruin Date: Tue, 3 May 2022 10:21:17 -0700 Subject: [PATCH 2/2] removed unnecessary namespaces --- .../Common/Instancing/RandomSeedGenerator.cs | 2 -- 1 file changed, 2 deletions(-) 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 12a53cbdac..5dc995ba36 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,11 +6,9 @@ //------------------------------------------------------------------------------ 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 {