Commit f9c7e582 authored by Nick Craver's avatar Nick Craver

Tests: move SubscriptionsSurviveConnectionFailure to async

parent 79278c62
...@@ -254,29 +254,31 @@ public void TestPatternPubSub(bool preserveOrder) ...@@ -254,29 +254,31 @@ public void TestPatternPubSub(bool preserveOrder)
#if DEBUG #if DEBUG
[Fact] [Fact]
public void SubscriptionsSurviveConnectionFailure() public async Task SubscriptionsSurviveConnectionFailureAsync()
{ {
using (var muxer = Create(allowAdmin: true)) using (var muxer = Create(allowAdmin: true))
{ {
RedisChannel channel = Me(); RedisChannel channel = Me();
var sub = muxer.GetSubscriber(); var sub = muxer.GetSubscriber();
int counter = 0; int counter = 0;
sub.Subscribe(channel, delegate await sub.SubscribeAsync(channel, delegate
{ {
Interlocked.Increment(ref counter); Interlocked.Increment(ref counter);
}); }).ConfigureAwait(false);
sub.Publish(channel, "abc"); await sub.PublishAsync(channel, "abc").ConfigureAwait(false);
sub.Ping(); sub.Ping();
await Task.Delay(200).ConfigureAwait(false);
Assert.Equal(1, VolatileWrapper.Read(ref counter)); Assert.Equal(1, VolatileWrapper.Read(ref counter));
var server = GetServer(muxer); var server = GetServer(muxer);
Assert.Equal(1, server.GetCounters().Subscription.SocketCount); Assert.Equal(1, server.GetCounters().Subscription.SocketCount);
server.SimulateConnectionFailure(); server.SimulateConnectionFailure();
SetExpectedAmbientFailureCount(2); SetExpectedAmbientFailureCount(2);
Thread.Sleep(100); await Task.Delay(200).ConfigureAwait(false);
sub.Ping(); sub.Ping();
Assert.Equal(2, server.GetCounters().Subscription.SocketCount); Assert.Equal(2, server.GetCounters().Subscription.SocketCount);
sub.Publish(channel, "abc"); await sub.PublishAsync(channel, "abc").ConfigureAwait(false);
await Task.Delay(200).ConfigureAwait(false);
sub.Ping(); sub.Ping();
Assert.Equal(2, VolatileWrapper.Read(ref counter)); Assert.Equal(2, VolatileWrapper.Read(ref counter));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment