diff --git a/GrowthBook.Tests/ApiTests/FeatureRefreshWorkerTests.cs b/GrowthBook.Tests/ApiTests/FeatureRefreshWorkerTests.cs index 938708e..a6e2aac 100644 --- a/GrowthBook.Tests/ApiTests/FeatureRefreshWorkerTests.cs +++ b/GrowthBook.Tests/ApiTests/FeatureRefreshWorkerTests.cs @@ -153,7 +153,7 @@ public async Task HttpResponseWithServerSentEventSupportWillStartBackgroundListe // incrementally move forward when it's appropriate. var cachedResults = new ConcurrentQueue>(); - var resetEvent = new AutoResetEvent(false); + var resetEvent = new ManualResetEventSlim(false); _cache .RefreshWith(Arg.Any>(), Arg.Any()) @@ -161,13 +161,16 @@ public async Task HttpResponseWithServerSentEventSupportWillStartBackgroundListe .AndDoes(x => { cachedResults.Enqueue((IDictionary)x[0]); - resetEvent.Set(); + + if (cachedResults.Count > 1) + { + resetEvent.Set(); + } }); var features = await _worker.RefreshCacheFromApi(); - resetEvent.WaitOne(5000).Should().BeTrue("because the cache should be refreshed within 5 seconds"); - resetEvent.WaitOne(5000).Should().BeTrue("because the cache should be refreshed again within 5 seconds"); + resetEvent.Wait(5000).Should().BeTrue("because the cache should be refreshed within 5 seconds"); _worker.Cancel();