From a5cd72cdc0ed790e6385b0ce5ea0e63abef86ce2 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Thu, 14 Sep 2023 17:16:39 +0530 Subject: [PATCH] Unskipped resume failure test for connection resume --- .../Realtime/ConnectionSandBoxSpecs.cs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/IO.Ably.Tests.Shared/Realtime/ConnectionSandBoxSpecs.cs b/src/IO.Ably.Tests.Shared/Realtime/ConnectionSandBoxSpecs.cs index 37c96cb13..6b26069f9 100644 --- a/src/IO.Ably.Tests.Shared/Realtime/ConnectionSandBoxSpecs.cs +++ b/src/IO.Ably.Tests.Shared/Realtime/ConnectionSandBoxSpecs.cs @@ -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) @@ -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); @@ -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(); }