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 2ea0768
Showing 1 changed file with 29 additions and 0 deletions.
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).IsSubsetOf(fallbackHosts).Should().BeTrue();
}

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

0 comments on commit 2ea0768

Please sign in to comment.