Skip to content

Commit

Permalink
Added test to check for provided custom fallback hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Apr 19, 2024
1 parent 3054ce5 commit c2d5739
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public async void TimeoutElapsedSignalsOnTimeout()
sut.TimeoutExpired.Should().BeTrue();
}
}
}
}
29 changes: 29 additions & 0 deletions src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,35 @@ public async Task ShouldUseCustomFallbackHostIfProvided()
attemptedList[1].Should().Be("www.example.com");
}

[Fact]
[Trait("spec", "RSC15a")]
[Trait("spec", "TO3k6")]
public async Task ShouldUseCustomFallbackHostIfProvidedAndDefaultHostIsDifferent()
{
_response.StatusCode = HttpStatusCode.BadGateway;
var attemptedList = new List<string>();
var fallbackHosts = new[]
{
"www.example1.com",
"www.example2.com",
"www.example3.com",
"www.example4.com",
"www.example5.com"
};
var client = CreateClient(options =>
{
options.RestHost = "www.primaryhost.com";
options.FallbackHosts = fallbackHosts;
options.HttpMaxRetryCount = 5;
});
await Assert.ThrowsAsync<AblyException>(() => MakeAnyRequest(client));
attemptedList.AddRange(_handler.Requests.Select(x => x.RequestUri.Host).ToList());

attemptedList.Count.Should().Be(6);
attemptedList[0].Should().Be("www.primaryhost.com");
attemptedList.Skip(1).Should().BeEquivalentTo(fallbackHosts);
}

[Fact]
[Trait("spec", "RSC15a")]
[Trait("spec", "TO3k6")]
Expand Down

0 comments on commit c2d5739

Please sign in to comment.