From 2ea0768f564df0603729ae82213e7ffdc563290e Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Fri, 19 Apr 2024 10:34:05 +0530 Subject: [PATCH] Added test to check for provided custom fallback hosts --- src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs b/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs index f492b097c..08a112fec 100644 --- a/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs +++ b/src/IO.Ably.Tests.Shared/Rest/RestSpecs.cs @@ -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(); + 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(() => 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")]