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)); }