Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public static IServiceCollection AddSignalRServiceManager<TOptionsSetup>(this IS
public static IServiceCollection AddHub<THub>(this IServiceCollection services, string hubName)
where THub : Hub
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(hubName);
#else
if (hubName is null)
{
throw new ArgumentNullException(nameof(hubName));
}
#endif

//for persistent
//use TryAdd to avoid overriding the test implementation added before.
services.TryAddSingleton<IServiceConnectionContainer>(sp => sp.GetRequiredService<MultiEndpointConnectionContainerFactory>().Create(hubName));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
Expand Down Expand Up @@ -64,12 +64,15 @@ private async Task<IHost> CreateAndStartHost(CancellationToken cancellationToken
}
catch
{
using (host)
if (host is not null)
{
await host.StopAsync(CancellationToken.None);
using (host)
{
await host.StopAsync(CancellationToken.None);
}
}
throw;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ public async Task HttpClientMessageTracingIdDisabledTestAsync(string httpClientN
await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, "http://abc"));
}

[Fact]
public void AddHub_HubNameNull_Throw()
{
Assert.Throws<ArgumentNullException>(
() => new ServiceCollection().AddHub<Hub>(null));
}

private sealed class WaitInfinitelyHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Expand Down