Skip to content

Commit

Permalink
Unskipped resume failure test for connection resume
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Sep 14, 2023
1 parent 95d2917 commit a5cd72c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/IO.Ably.Tests.Shared/Realtime/ConnectionSandBoxSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ await WaitForMultiple(channelCount, partialDone =>
attachedChannels.Should().HaveCount(channelCount);
}

[Theory(Skip = "Keeps failing")]
[Theory]
[ProtocolData]
[Trait("spec", "RTN15c4")]
public async Task ResumeRequest_WithFatalErrorInConnection_ClientAndChannelsShouldBecomeFailed(Protocol protocol)
Expand All @@ -673,9 +673,11 @@ public async Task ResumeRequest_WithFatalErrorInConnection_ClientAndChannelsShou
{
options.DisconnectedRetryTimeout = TimeSpan.FromSeconds(2);
});
await client.WaitForState(ConnectionState.Connected);

var channel = (RealtimeChannel)client.Channels.Get("RTN15c4".AddRandomSuffix());
channel.Attach();
await client.WaitForState(ConnectionState.Connected);
await channel.WaitForAttachedState();

client.GetTestTransport().Close(false);
await client.WaitForState(ConnectionState.Disconnected);
Expand All @@ -693,28 +695,30 @@ public async Task ResumeRequest_WithFatalErrorInConnection_ClientAndChannelsShou
});
});

ConnectionStateChange stateChange = null;
ConnectionStateChange failedStateChange = null;
await WaitFor(done =>
{
client.Connection.Once(ConnectionEvent.Failed, change =>
{
stateChange = change;
failedStateChange = change;
done();
});
});

stateChange.Reason.Code.Should().Be(errInfo.Code);
stateChange.Reason.Message.Should().Be(errInfo.Message);
failedStateChange.Previous.Should().Be(ConnectionState.Connecting);
failedStateChange.Current.Should().Be(ConnectionState.Failed);
failedStateChange.Reason.Code.Should().Be(errInfo.Code);
failedStateChange.Reason.Message.Should().Be(errInfo.Message);

client.Connection.ErrorReason.Code.Should().Be(errInfo.Code);
client.Connection.ErrorReason.Message.Should().Be(errInfo.Message);
client.Connection.State.Should().Be(ConnectionState.Failed);

await channel.WaitForState(ChannelState.Failed);
channel.State.Should().Be(ChannelState.Failed);
channel.ErrorReason.Code.Should().Be(errInfo.Code);
channel.ErrorReason.Message.Should().Be(errInfo.Message);

client.Connection.ErrorReason.Code.Should().Be(errInfo.Code);
client.Connection.ErrorReason.Message.Should().Be(errInfo.Message);
client.Connection.State.Should().Be(ConnectionState.Failed);

client.Close();
}

Expand Down

0 comments on commit a5cd72c

Please sign in to comment.