From 16885d56b0702e74a4c4b2e0a2a2835cb2764664 Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Wed, 21 Aug 2024 12:11:41 +0200 Subject: [PATCH] Attempt at fixing occasionally failing tests --- src/ConfigCat.Client.Tests/ConfigServiceTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ConfigCat.Client.Tests/ConfigServiceTests.cs b/src/ConfigCat.Client.Tests/ConfigServiceTests.cs index feb462c3..24765d58 100644 --- a/src/ConfigCat.Client.Tests/ConfigServiceTests.cs +++ b/src/ConfigCat.Client.Tests/ConfigServiceTests.cs @@ -762,6 +762,8 @@ public async Task AutoPollConfigService_GetConfig_FetchesConfigWhenCachedConfigI cts.Cancel(); clientReadyCalled = task == clientReadyTask && task.Status == TaskStatus.RanToCompletion; + await Task.Yield(); + // Wait for the hook event handlers to execute (as that might not happen if the service got disposed immediately). SpinWait.SpinUntil(() => configFetchedEvents.TryPeek(out _), TimeSpan.FromSeconds(1)); } @@ -835,6 +837,8 @@ public async Task AutoPollConfigService_GetConfig_ReturnsExpiredConfigWhenCantRe cts.Cancel(); clientReadyCalled = task == clientReadyTask && task.Status == TaskStatus.RanToCompletion; + await Task.Yield(); + // Wait for the hook event handlers to execute (as that might not happen if the service got disposed immediately). SpinWait.SpinUntil(() => configFetchedEvents.TryPeek(out _), TimeSpan.FromSeconds(1)); }