Skip to content

Commit f9c7e58

Browse files
committed
Tests: move SubscriptionsSurviveConnectionFailure to async
1 parent 79278c6 commit f9c7e58

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

StackExchange.Redis.Tests/PubSub.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,29 +254,31 @@ public void TestPatternPubSub(bool preserveOrder)
254254

255255
#if DEBUG
256256
[Fact]
257-
public void SubscriptionsSurviveConnectionFailure()
257+
public async Task SubscriptionsSurviveConnectionFailureAsync()
258258
{
259259
using (var muxer = Create(allowAdmin: true))
260260
{
261261
RedisChannel channel = Me();
262262
var sub = muxer.GetSubscriber();
263263
int counter = 0;
264-
sub.Subscribe(channel, delegate
264+
await sub.SubscribeAsync(channel, delegate
265265
{
266266
Interlocked.Increment(ref counter);
267-
});
268-
sub.Publish(channel, "abc");
267+
}).ConfigureAwait(false);
268+
await sub.PublishAsync(channel, "abc").ConfigureAwait(false);
269269
sub.Ping();
270+
await Task.Delay(200).ConfigureAwait(false);
270271
Assert.Equal(1, VolatileWrapper.Read(ref counter));
271272
var server = GetServer(muxer);
272273
Assert.Equal(1, server.GetCounters().Subscription.SocketCount);
273274

274275
server.SimulateConnectionFailure();
275276
SetExpectedAmbientFailureCount(2);
276-
Thread.Sleep(100);
277+
await Task.Delay(200).ConfigureAwait(false);
277278
sub.Ping();
278279
Assert.Equal(2, server.GetCounters().Subscription.SocketCount);
279-
sub.Publish(channel, "abc");
280+
await sub.PublishAsync(channel, "abc").ConfigureAwait(false);
281+
await Task.Delay(200).ConfigureAwait(false);
280282
sub.Ping();
281283
Assert.Equal(2, VolatileWrapper.Read(ref counter));
282284
}
@@ -295,4 +297,4 @@ public static int Read(ref int location)
295297
#endif
296298
}
297299
}
298-
}
300+
}

0 commit comments

Comments
 (0)