From ed7295f56b23dd14a00e6f6746972e3a866f103b Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Tue, 9 Jan 2024 15:19:23 +0100 Subject: [PATCH] Fix occasionally failing tests (increase tolerance of timing checks) --- src/ConfigCat.Client.Tests/ConfigCatClientTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ConfigCat.Client.Tests/ConfigCatClientTests.cs b/src/ConfigCat.Client.Tests/ConfigCatClientTests.cs index 63c15456..6ccb023a 100644 --- a/src/ConfigCat.Client.Tests/ConfigCatClientTests.cs +++ b/src/ConfigCat.Client.Tests/ConfigCatClientTests.cs @@ -217,7 +217,7 @@ public async Task Initialization_AutoPoll_WithMaxInitWaitTime_GetValueShouldWait sw.Stop(); - Assert.IsTrue(sw.Elapsed >= delay - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}"); + Assert.IsTrue(sw.Elapsed >= delay - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance Assert.IsTrue(sw.Elapsed <= delay + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance Assert.IsTrue(actualValue); } @@ -252,7 +252,7 @@ public async Task Initialization_AutoPoll_WithMaxInitWaitTime_GetValueShouldWait sw.Stop(); - Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}"); + Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance Assert.IsTrue(sw.Elapsed <= maxInitWaitTime + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance Assert.IsFalse(actualValue); @@ -312,7 +312,7 @@ public async Task WaitForReadyAsync_AutoPoll_ShouldWaitForMaxInitWaitTime() sw.Stop(); - Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}"); + Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance Assert.IsTrue(sw.Elapsed <= maxInitWaitTime + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance Assert.AreEqual(ClientCacheState.NoFlagData, cacheState); @@ -360,7 +360,7 @@ public async Task WaitForReadyAsync_AutoPoll_ShouldWaitForMaxInitWaitTimeAndRetu sw.Stop(); - Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}"); + Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance Assert.IsTrue(sw.Elapsed <= maxInitWaitTime + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance Assert.AreEqual(ClientCacheState.HasCachedFlagDataOnly, cacheState);