Merge pull request #2224 from aspnet/release/2.1
Use params passed into HubConnectionBuilder (#2223)
This commit is contained in:
commit
62d892315b
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
||||||
/// <returns>The same instance of the <see cref="IHubConnectionBuilder"/> for chaining.</returns>
|
/// <returns>The same instance of the <see cref="IHubConnectionBuilder"/> for chaining.</returns>
|
||||||
public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url, HttpTransportType transports)
|
public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url, HttpTransportType transports)
|
||||||
{
|
{
|
||||||
hubConnectionBuilder.WithUrlCore(url, null, _ => { });
|
hubConnectionBuilder.WithUrlCore(url, transports, _ => { });
|
||||||
return hubConnectionBuilder;
|
return hubConnectionBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
||||||
/// <returns>The same instance of the <see cref="IHubConnectionBuilder"/> for chaining.</returns>
|
/// <returns>The same instance of the <see cref="IHubConnectionBuilder"/> for chaining.</returns>
|
||||||
public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url, HttpTransportType transports, Action<HttpConnectionOptions> configureHttpConnection)
|
public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url, HttpTransportType transports, Action<HttpConnectionOptions> configureHttpConnection)
|
||||||
{
|
{
|
||||||
hubConnectionBuilder.WithUrlCore(url, transports, _ => { });
|
hubConnectionBuilder.WithUrlCore(url, transports, configureHttpConnection);
|
||||||
return hubConnectionBuilder;
|
return hubConnectionBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,36 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
Assert.Equal(HttpTransportType.LongPolling, value.Transports);
|
Assert.Equal(HttpTransportType.LongPolling, value.Transports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WithUrlUsingUriSetsTransport()
|
||||||
|
{
|
||||||
|
var connectionBuilder = new HubConnectionBuilder();
|
||||||
|
var uri = new Uri("http://tempuri.org");
|
||||||
|
connectionBuilder.WithUrl(uri, HttpTransportType.LongPolling);
|
||||||
|
|
||||||
|
var serviceProvider = connectionBuilder.Services.BuildServiceProvider();
|
||||||
|
|
||||||
|
var value = serviceProvider.GetService<IOptions<HttpConnectionOptions>>().Value;
|
||||||
|
|
||||||
|
Assert.Equal(HttpTransportType.LongPolling, value.Transports);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WithUrlUsingUriHttpConnectionCallsConfigure()
|
||||||
|
{
|
||||||
|
var proxy = Mock.Of<IWebProxy>();
|
||||||
|
|
||||||
|
var connectionBuilder = new HubConnectionBuilder();
|
||||||
|
var uri = new Uri("http://tempuri.org");
|
||||||
|
connectionBuilder.WithUrl(uri, HttpTransportType.LongPolling, options => { options.Proxy = proxy; });
|
||||||
|
|
||||||
|
var serviceProvider = connectionBuilder.Services.BuildServiceProvider();
|
||||||
|
|
||||||
|
var value = serviceProvider.GetService<IOptions<HttpConnectionOptions>>().Value;
|
||||||
|
|
||||||
|
Assert.Same(proxy, value.Proxy);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void WithHttpConnectionCallsConfigure()
|
public void WithHttpConnectionCallsConfigure()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue