public static async Task Using_The_Same_Builder_For_Multiple_Registrations_With_Custom_Ports() { // Arrange var options = new HttpClientInterceptorOptions() { ThrowOnMissingRegistration = true }; var builder = new HttpRequestInterceptionBuilder() .ForPort(123) .ForHttps() .ForHost("api.github.com") .ForPath("orgs/justeat") .RegisterWith(options); // Change to a different scheme without changing the port builder = builder .ForHttp() .RegisterWith(options); // Change the port and not the scheme builder = builder .ForPort(456) .RegisterWith(options); // Change the scheme and use an explicit port builder = builder .ForHttps() .ForPort(443) .RegisterWith(options); // Restore default scheme and port builder = builder .ForHttp() .ForPort(-1) .RegisterWith(options); // Act and Assert await HttpAssert.GetAsync(options, "https://api.github.com:123/orgs/justeat"); await HttpAssert.GetAsync(options, "http://api.github.com:123/orgs/justeat"); await HttpAssert.GetAsync(options, "http://api.github.com:456/orgs/justeat"); await HttpAssert.GetAsync(options, "https://api.github.com/orgs/justeat"); await HttpAssert.GetAsync(options, "https://api.github.com:443/orgs/justeat"); await HttpAssert.GetAsync(options, "http://api.github.com/orgs/justeat"); await HttpAssert.GetAsync(options, "http://api.github.com:80/orgs/justeat"); }
public static async Task Using_The_Same_Builder_For_Multiple_Registrations_On_The_Same_Host_Retains_Default_Port() { // Arrange var options = new HttpClientInterceptorOptions() { ThrowOnMissingRegistration = true }; var builder = new HttpRequestInterceptionBuilder() .ForHttps() .ForHost("api.github.com") .ForPath("orgs/justeat") .RegisterWith(options); // Change to a different scheme without an explicit port builder = builder .ForHttp() .RegisterWith(options); // Act and Assert await HttpAssert.GetAsync(options, "http://api.github.com/orgs/justeat"); await HttpAssert.GetAsync(options, "http://api.github.com:80/orgs/justeat"); await HttpAssert.GetAsync(options, "https://api.github.com/orgs/justeat"); await HttpAssert.GetAsync(options, "https://api.github.com:443/orgs/justeat"); }