[SignalR] Move to generic host (#22602)
This commit is contained in:
parent
6a4d79cfb8
commit
a1c226e4f3
|
|
@ -16,7 +16,7 @@
|
|||
<Reference Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<Reference Include="Microsoft.Extensions.FileProviders.Physical" />
|
||||
<Reference Include="Microsoft.Extensions.FileProviders.Composite" />
|
||||
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
|
||||
<Reference Include="Microsoft.Extensions.Hosting" />
|
||||
<Reference Include="Microsoft.Extensions.Logging" />
|
||||
<Reference Include="Microsoft.Extensions.Options" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core hosting infrastructure and startup logic for web applications.</Description>
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
<Reference Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<Reference Include="Microsoft.Extensions.FileProviders.Physical" />
|
||||
<Reference Include="Microsoft.Extensions.FileProviders.Composite" />
|
||||
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
|
||||
<Reference Include="Microsoft.Extensions.Hosting" />
|
||||
<Reference Include="Microsoft.Extensions.Logging" />
|
||||
<Reference Include="Microsoft.Extensions.Options" />
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CheckFixedMessage(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -125,7 +125,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
|
||||
var protocol = HubProtocols["json"];
|
||||
using (var server = await StartServer<Startup>(ExpectedError))
|
||||
await using (var server = await StartServer<Startup>(ExpectedError))
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ClientCanConnectToServerWithLowerMinimumProtocol()
|
||||
{
|
||||
var protocol = HubProtocols["json"];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -185,7 +185,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanSendAndReceiveMessage(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
|
|
@ -214,7 +214,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanSendNull(string protocolName)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.LongPolling, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -243,7 +243,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStopAndStartConnection(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
|
|
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanAccessConnectionIdFromHubConnection(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -310,7 +310,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStartConnectionFromClosedEvent(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<HubConnectionTests>();
|
||||
const string originalMessage = "SignalR";
|
||||
|
|
@ -372,7 +372,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task MethodsAreCaseInsensitive(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
|
|
@ -402,7 +402,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanInvokeFromOnHandler(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
|
||||
|
|
@ -442,7 +442,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncCoreTest(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -477,7 +477,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamToHubWithIAsyncEnumerableMethodArg(string protocolName)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.WebSockets, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -523,7 +523,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncTest(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -558,7 +558,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -595,7 +595,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncCanBeCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -643,7 +643,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -679,7 +679,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanInvokeClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
|
||||
|
|
@ -713,7 +713,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task InvokeNonExistantClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
var closeTcs = new TaskCompletionSource();
|
||||
|
|
@ -755,7 +755,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -785,7 +785,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamToAndFromClientInSameInvocation(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -822,7 +822,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamToServerWithIAsyncEnumerable(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -869,7 +869,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanCancelIAsyncEnumerableClientToServerUpload(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -922,7 +922,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncCanBeCanceledThroughGetAsyncEnumerator(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -963,7 +963,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanCloseStreamMethodEarly(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1004,7 +1004,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1039,7 +1039,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1067,7 +1067,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfHubMethodCannotBeResolved(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1094,7 +1094,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfHubMethodCannotBeResolvedAndArgumentsPassedIn(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1121,7 +1121,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnHubMethodArgumentCountMismatch(string hubProtocolName)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.LongPolling, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1148,7 +1148,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnHubMethodArgumentTypeMismatch(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1175,7 +1175,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfStreamingHubMethodCannotBeResolved(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1203,7 +1203,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnStreamingHubMethodArgumentCountMismatch(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1231,7 +1231,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnStreamingHubMethodArgumentTypeMismatch(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1259,7 +1259,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfNonStreamMethodInvokedWithStreamAsync(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1286,7 +1286,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfStreamMethodInvokedWithInvoke(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1313,7 +1313,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfBuildingAsyncEnumeratorIsNotPossible(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1349,7 +1349,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
};
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>(write => write.EventId.Name == "FailedWritingMessage"))
|
||||
await using (var server = await StartServer<Startup>(write => write.EventId.Name == "FailedWritingMessage"))
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.WebSockets, protocol, LoggerFactory);
|
||||
var closedTcs = new TaskCompletionSource<Exception>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
|
@ -1396,7 +1396,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
};
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (var server = await StartServer<Startup>(write => write.EventId.Name == "FailedWritingMessage"))
|
||||
await using (var server = await StartServer<Startup>(write => write.EventId.Name == "FailedWritingMessage"))
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.LongPolling, protocol, LoggerFactory);
|
||||
var closedTcs = new TaskCompletionSource<Exception>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
|
@ -1436,7 +1436,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
var hubProtocol = HubProtocols.First().Value;
|
||||
var transportType = TransportTypes().First().Cast<HttpTransportType>().First();
|
||||
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
await connection.StartAsync().OrTimeout();
|
||||
|
|
@ -1453,7 +1453,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientCanUseJwtBearerTokenForAuthentication(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
async Task<string> AccessTokenProvider()
|
||||
{
|
||||
|
|
@ -1496,7 +1496,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
return writeContext.Exception is HttpRequestException;
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1518,7 +1518,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientCanUseJwtBearerTokenForAuthenticationWhenRedirected(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1546,7 +1546,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientCanSendHeaders(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1577,7 +1577,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserAgentIsSet()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1619,7 +1619,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserAgentCanBeCleared()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1654,7 +1654,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserAgentCanBeSet()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1690,7 +1690,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketOptionsAreApplied()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
// System.Net has a HttpTransportType type which means we need to fully-qualify this rather than 'use' the namespace
|
||||
var cookieJar = new System.Net.CookieContainer();
|
||||
|
|
@ -1724,7 +1724,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task CheckHttpConnectionFeatures()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1760,7 +1760,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserIdProviderCanAccessHttpContext()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1791,7 +1791,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task NegotiationSkipsServerSentEventsWhenUsingBinaryProtocol()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1821,7 +1821,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task StopCausesPollToReturnImmediately()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
PollTrackingMessageHandler pollTracker = null;
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
|
|
@ -1869,7 +1869,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
writeContext.EventId.Name == "ReconnectingWithError";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = CreateHubConnection(
|
||||
server.Url,
|
||||
|
|
@ -1931,7 +1931,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
writeContext.EventId.Name == "ReconnectingWithError";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1991,7 +1991,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
writeContext.EventId.Name == "ReconnectingWithError";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientUsingOldCallWithOriginalProtocol(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<VersionStartup>())
|
||||
await using (var server = await StartServer<VersionStartup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientUsingOldCallWithNewProtocol(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<VersionStartup>())
|
||||
await using (var server = await StartServer<VersionStartup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientUsingNewCallWithNewProtocol(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<VersionStartup>())
|
||||
await using (var server = await StartServer<VersionStartup>())
|
||||
{
|
||||
var httpConnectionFactory = new HttpConnectionFactory(
|
||||
Options.Create(new HttpConnectionOptions
|
||||
|
|
@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
return writeContext.LoggerName == typeof(HubConnection).FullName;
|
||||
}
|
||||
|
||||
using (var server = await StartServer<VersionStartup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<VersionStartup>(ExpectedErrors))
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ using System;
|
|||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Win32;
|
||||
|
||||
|
|
@ -13,7 +15,7 @@ namespace FunctionalTests
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
public static Task Main(string[] args)
|
||||
{
|
||||
string url = null;
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
|
|
@ -27,65 +29,69 @@ namespace FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
var hostBuilder = new WebHostBuilder()
|
||||
.ConfigureLogging(factory =>
|
||||
var hostBuilder = new HostBuilder()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
factory.AddConsole(options =>
|
||||
webHostBuilder
|
||||
.ConfigureLogging(factory =>
|
||||
{
|
||||
options.IncludeScopes = true;
|
||||
options.TimestampFormat = "[HH:mm:ss] ";
|
||||
options.UseUtcTimestamp = true;
|
||||
});
|
||||
factory.AddDebug();
|
||||
factory.SetMinimumLevel(LogLevel.Debug);
|
||||
})
|
||||
.UseKestrel((builderContext, options) =>
|
||||
{
|
||||
options.ConfigureHttpsDefaults(httpsOptions =>
|
||||
{
|
||||
bool useRSA = false;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
factory.AddConsole(options =>
|
||||
{
|
||||
// Detect Win10+
|
||||
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
|
||||
var major = key.GetValue("CurrentMajorVersionNumber") as int?;
|
||||
var minor = key.GetValue("CurrentMinorVersionNumber") as int?;
|
||||
options.IncludeScopes = true;
|
||||
options.TimestampFormat = "[HH:mm:ss] ";
|
||||
options.UseUtcTimestamp = true;
|
||||
});
|
||||
factory.AddDebug();
|
||||
factory.SetMinimumLevel(LogLevel.Debug);
|
||||
})
|
||||
.UseKestrel((builderContext, options) =>
|
||||
{
|
||||
options.ConfigureHttpsDefaults(httpsOptions =>
|
||||
{
|
||||
bool useRSA = false;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Detect Win10+
|
||||
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
|
||||
var major = key.GetValue("CurrentMajorVersionNumber") as int?;
|
||||
var minor = key.GetValue("CurrentMinorVersionNumber") as int?;
|
||||
|
||||
if (major.HasValue && minor.HasValue)
|
||||
if (major.HasValue && minor.HasValue)
|
||||
{
|
||||
useRSA = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
useRSA = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
useRSA = true;
|
||||
}
|
||||
|
||||
if (useRSA)
|
||||
{
|
||||
// RSA cert, won't work on Windows 8.1 & Windows 2012 R2 using HTTP2, and ECC won't work in some Node environments
|
||||
var certPath = Path.Combine(Directory.GetCurrentDirectory(), "testCert.pfx");
|
||||
httpsOptions.ServerCertificate = new X509Certificate2(certPath, "testPassword");
|
||||
}
|
||||
else
|
||||
{
|
||||
// ECC cert, works on Windows 8.1 & Windows 2012 R2 using HTTP2
|
||||
var certPath = Path.Combine(Directory.GetCurrentDirectory(), "testCertECC.pfx");
|
||||
httpsOptions.ServerCertificate = new X509Certificate2(certPath, "testPassword");
|
||||
}
|
||||
});
|
||||
})
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>();
|
||||
if (useRSA)
|
||||
{
|
||||
// RSA cert, won't work on Windows 8.1 & Windows 2012 R2 using HTTP2, and ECC won't work in some Node environments
|
||||
var certPath = Path.Combine(Directory.GetCurrentDirectory(), "testCert.pfx");
|
||||
httpsOptions.ServerCertificate = new X509Certificate2(certPath, "testPassword");
|
||||
}
|
||||
else
|
||||
{
|
||||
// ECC cert, works on Windows 8.1 & Windows 2012 R2 using HTTP2
|
||||
var certPath = Path.Combine(Directory.GetCurrentDirectory(), "testCertECC.pfx");
|
||||
httpsOptions.ServerCertificate = new X509Certificate2(certPath, "testPassword");
|
||||
}
|
||||
});
|
||||
})
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>();
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
Console.WriteLine($"Forcing URL to: {url}");
|
||||
hostBuilder.UseUrls(url);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
Console.WriteLine($"Forcing URL to: {url}");
|
||||
webHostBuilder.UseUrls(url);
|
||||
}
|
||||
});
|
||||
|
||||
hostBuilder.Build().Run();
|
||||
return hostBuilder.Build().RunAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ using Microsoft.AspNetCore.Connections;
|
|||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting.Server;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.SignalR.Tests;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
|
@ -305,7 +307,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task MapConnectionHandlerWithWebSocketSubProtocolSetsProtocol()
|
||||
{
|
||||
var host = BuildWebHost<MyConnectionHandler>("/socket",
|
||||
using var host = BuildWebHost<MyConnectionHandler>("/socket",
|
||||
options => options.WebSockets.SubProtocolSelector = subprotocols =>
|
||||
{
|
||||
Assert.Equal(new[] { "protocol1", "protocol2" }, subprotocols.ToArray());
|
||||
|
|
@ -314,7 +316,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
|
||||
await host.StartAsync();
|
||||
|
||||
var feature = host.ServerFeatures.Get<IServerAddressesFeature>();
|
||||
var feature = host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>();
|
||||
var address = feature.Addresses.First().Replace("http", "ws") + "/socket";
|
||||
|
||||
var client = new ClientWebSocket();
|
||||
|
|
@ -377,44 +379,52 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
}
|
||||
}
|
||||
|
||||
private IWebHost BuildWebHost(Action<IEndpointRouteBuilder> configure)
|
||||
private IHost BuildWebHost(Action<IEndpointRouteBuilder> configure)
|
||||
{
|
||||
return new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.ConfigureServices(services =>
|
||||
return new HostBuilder()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
services.AddConnections();
|
||||
webHostBuilder
|
||||
.UseKestrel()
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
services.AddConnections();
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints => configure(endpoints));
|
||||
})
|
||||
.UseUrls("http://127.0.0.1:0");
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints => configure(endpoints));
|
||||
})
|
||||
.UseUrls("http://127.0.0.1:0")
|
||||
.Build();
|
||||
}
|
||||
|
||||
private IWebHost BuildWebHost<TConnectionHandler>(string path, Action<HttpConnectionDispatcherOptions> configureOptions) where TConnectionHandler : ConnectionHandler
|
||||
private IHost BuildWebHost<TConnectionHandler>(string path, Action<HttpConnectionDispatcherOptions> configureOptions) where TConnectionHandler : ConnectionHandler
|
||||
{
|
||||
return new WebHostBuilder()
|
||||
.UseUrls("http://127.0.0.1:0")
|
||||
.UseKestrel()
|
||||
.ConfigureServices(services =>
|
||||
return new HostBuilder()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
services.AddConnections();
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(routes =>
|
||||
webHostBuilder
|
||||
.UseUrls("http://127.0.0.1:0")
|
||||
.UseKestrel()
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
routes.MapConnectionHandler<TConnectionHandler>(path, configureOptions);
|
||||
services.AddConnections();
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(routes =>
|
||||
{
|
||||
routes.MapConnectionHandler<TConnectionHandler>(path, configureOptions);
|
||||
});
|
||||
})
|
||||
.ConfigureLogging(factory =>
|
||||
{
|
||||
factory.AddXunit(_output, LogLevel.Trace);
|
||||
});
|
||||
})
|
||||
.ConfigureLogging(factory =>
|
||||
{
|
||||
factory.AddXunit(_output, LogLevel.Trace);
|
||||
})
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting.Server;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Tests
|
||||
{
|
||||
public abstract class InProcessTestServer : IDisposable
|
||||
public abstract class InProcessTestServer : IAsyncDisposable
|
||||
{
|
||||
internal abstract event Action<LogRecord> ServerLogged;
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
public abstract string Url { get; }
|
||||
|
||||
public abstract void Dispose();
|
||||
public abstract ValueTask DisposeAsync();
|
||||
}
|
||||
|
||||
public class InProcessTestServer<TStartup> : InProcessTestServer
|
||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly ILogger _logger;
|
||||
private IWebHost _host;
|
||||
private IHost _host;
|
||||
private IHostApplicationLifetime _lifetime;
|
||||
private readonly IDisposable _logToken;
|
||||
private readonly IDisposable _extraDisposable;
|
||||
|
|
@ -91,15 +91,18 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
// We're using 127.0.0.1 instead of localhost to ensure that we use IPV4 across different OSes
|
||||
var url = "http://127.0.0.1:0";
|
||||
|
||||
_host = new WebHostBuilder()
|
||||
.ConfigureLogging(builder => builder
|
||||
_host = new HostBuilder()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
webHostBuilder
|
||||
.ConfigureLogging(builder => builder
|
||||
.SetMinimumLevel(LogLevel.Trace)
|
||||
.AddProvider(new ForwardingLoggerProvider(_loggerFactory)))
|
||||
.UseStartup(typeof(TStartup))
|
||||
.UseKestrel()
|
||||
.UseUrls(url)
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.Build();
|
||||
.UseStartup(typeof(TStartup))
|
||||
.UseKestrel()
|
||||
.UseUrls(url)
|
||||
.UseContentRoot(Directory.GetCurrentDirectory());
|
||||
}).Build();
|
||||
|
||||
_logger.LogInformation("Starting test server...");
|
||||
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
||||
|
|
@ -116,7 +119,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
_logger.LogInformation("Test Server started");
|
||||
|
||||
// Get the URL from the server
|
||||
_url = _host.ServerFeatures.Get<IServerAddressesFeature>().Addresses.Single();
|
||||
_url = _host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.Single();
|
||||
|
||||
_lifetime = _host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
_lifetime.ApplicationStopped.Register(() =>
|
||||
|
|
@ -144,12 +147,19 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
return builder.ToString();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
public override async ValueTask DisposeAsync()
|
||||
{
|
||||
_extraDisposable?.Dispose();
|
||||
_logger.LogInformation("Shutting down test server");
|
||||
_host.Dispose();
|
||||
_loggerFactory.Dispose();
|
||||
try
|
||||
{
|
||||
_extraDisposable?.Dispose();
|
||||
_logger.LogInformation("Start shutting down test server");
|
||||
}
|
||||
finally
|
||||
{
|
||||
await _host.StopAsync();
|
||||
_host.Dispose();
|
||||
_loggerFactory.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private class ForwardingLoggerProvider : ILoggerProvider
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
|
||||
|
|
|
|||
|
|
@ -1,29 +1,35 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JwtSample
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
public static Task Main(string[] args)
|
||||
{
|
||||
new WebHostBuilder()
|
||||
.ConfigureLogging(factory =>
|
||||
return Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
factory.AddConsole();
|
||||
factory.AddFilter("Console", level => level >= LogLevel.Information);
|
||||
factory.AddDebug();
|
||||
webHostBuilder
|
||||
.ConfigureLogging(factory =>
|
||||
{
|
||||
factory.AddConsole();
|
||||
factory.AddFilter("Console", level => level >= LogLevel.Information);
|
||||
factory.AddDebug();
|
||||
})
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>();
|
||||
})
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>()
|
||||
.Build()
|
||||
.Run();
|
||||
.RunAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SignalRSamples.Hubs;
|
||||
|
||||
|
|
@ -13,36 +15,40 @@ namespace SignalRSamples
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
public static Task Main(string[] args)
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddCommandLine(args)
|
||||
.Build();
|
||||
|
||||
var host = new WebHostBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseSetting(WebHostDefaults.PreventHostingStartupKey, "true")
|
||||
.ConfigureLogging(factory =>
|
||||
var host = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
factory.AddConsole();
|
||||
})
|
||||
.UseKestrel(options =>
|
||||
{
|
||||
// Default port
|
||||
options.ListenLocalhost(5000);
|
||||
|
||||
// Hub bound to TCP end point
|
||||
options.Listen(IPAddress.Any, 9001, builder =>
|
||||
webHostBuilder
|
||||
.UseConfiguration(config)
|
||||
.UseSetting(WebHostDefaults.PreventHostingStartupKey, "true")
|
||||
.ConfigureLogging((c, factory) =>
|
||||
{
|
||||
builder.UseHub<Chat>();
|
||||
});
|
||||
})
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
factory.AddConfiguration(c.Configuration.GetSection("Logging"));
|
||||
factory.AddConsole();
|
||||
})
|
||||
.UseKestrel(options =>
|
||||
{
|
||||
// Default port
|
||||
options.ListenLocalhost(5000);
|
||||
|
||||
host.Run();
|
||||
// Hub bound to TCP end point
|
||||
options.Listen(IPAddress.Any, 9001, builder =>
|
||||
{
|
||||
builder.UseHub<Chat>();
|
||||
});
|
||||
})
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>();
|
||||
}).Build();
|
||||
|
||||
return host.RunAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,29 +2,35 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SocialWeather
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
public static Task Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.UseSetting(WebHostDefaults.PreventHostingStartupKey, "true")
|
||||
.ConfigureLogging(factory =>
|
||||
var host = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
factory.AddConsole();
|
||||
factory.AddFilter("Console", level => level >= LogLevel.Information);
|
||||
webHostBuilder
|
||||
.UseSetting(WebHostDefaults.PreventHostingStartupKey, "true")
|
||||
.ConfigureLogging(factory =>
|
||||
{
|
||||
factory.AddConsole();
|
||||
factory.AddFilter("Console", level => level >= LogLevel.Information);
|
||||
})
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>();
|
||||
})
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
return host.RunAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[Fact]
|
||||
public async Task CanStartAndStopConnectionUsingDefaultTransport()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var url = server.Url + "/echo";
|
||||
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
|
||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorStartingTransport";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(expectedErrorsFilter: ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(expectedErrorsFilter: ExpectedErrors))
|
||||
{
|
||||
var url = server.Url + "/echo";
|
||||
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
|
||||
|
|
@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[LogLevel(LogLevel.Trace)]
|
||||
public async Task CanStartAndStopConnectionUsingGivenTransport(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var url = server.Url + "/echo";
|
||||
var connection = new HttpConnection(new HttpConnectionOptions { Url = new Uri(url), Transports = transportType, DefaultTransferFormat = TransferFormat.Text }, LoggerFactory);
|
||||
|
|
@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTest()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsReceivesAndSendsPartialFramesTest()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task HttpRequestsNotSentWhenWebSocketsTransportRequestedAndSkipNegotiationSet()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
var url = server.Url + "/echo";
|
||||
|
|
@ -214,7 +214,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[InlineData(HttpTransportType.ServerSentEvents)]
|
||||
public async Task HttpConnectionThrowsIfSkipNegotiationSetAndTransportIsNotWebSockets(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
var url = server.Url + "/echo";
|
||||
|
|
@ -257,7 +257,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[LogLevel(LogLevel.Trace)]
|
||||
public async Task ConnectionCanSendAndReceiveMessages(HttpTransportType transportType, TransferFormat requestedTransferFormat)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
public async Task ConnectionCanSendAndReceiveDifferentMessageSizesWebSocketsTransport(int length)
|
||||
{
|
||||
var message = new string('A', length);
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -379,7 +379,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -403,7 +403,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorStartingTransport";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -433,7 +433,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
private async Task ServerClosesConnectionWithErrorIfHubCannotBeCreated(HttpTransportType transportType)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -604,7 +604,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
await using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.Http.Connections;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Tests
|
||||
|
|
@ -29,9 +30,11 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
public void NotAddingSignalRServiceThrows()
|
||||
{
|
||||
var executedConfigure = false;
|
||||
var builder = new WebHostBuilder();
|
||||
var builder = new HostBuilder();
|
||||
|
||||
builder
|
||||
builder.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
webHostBuilder
|
||||
.UseKestrel()
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
|
|
@ -54,6 +57,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
"'IServiceCollection.AddSignalR' inside the call to 'ConfigureServices(...)' in the application startup code.", ex.Message);
|
||||
})
|
||||
.UseUrls("http://127.0.0.1:0");
|
||||
});
|
||||
|
||||
using (var host = builder.Build())
|
||||
{
|
||||
|
|
@ -338,20 +342,24 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
}
|
||||
|
||||
private IWebHost BuildWebHost(Action<IEndpointRouteBuilder> configure)
|
||||
private IHost BuildWebHost(Action<IEndpointRouteBuilder> configure)
|
||||
{
|
||||
return new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.ConfigureServices(services =>
|
||||
return new HostBuilder()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
services.AddSignalR();
|
||||
webHostBuilder
|
||||
.UseKestrel()
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
services.AddSignalR();
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints => configure(endpoints));
|
||||
})
|
||||
.UseUrls("http://127.0.0.1:0");
|
||||
})
|
||||
.Configure(app =>
|
||||
{
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints => configure(endpoints));
|
||||
})
|
||||
.UseUrls("http://127.0.0.1:0")
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportStopsSendAndReceiveLoopsWhenTransportIsStopped()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/echo"),
|
||||
|
|
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportSendsUserAgent()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/httpheader"),
|
||||
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportSendsXRequestedWithHeader()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/httpheader"),
|
||||
|
|
@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportStopsWhenConnectionChannelClosed()
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/echo"),
|
||||
|
|
@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[InlineData(TransferFormat.Binary)]
|
||||
public async Task WebSocketsTransportStopsWhenConnectionClosedByTheServer(TransferFormat transferFormat)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/echoAndClose"), transferFormat);
|
||||
|
|
@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[InlineData(TransferFormat.Binary)]
|
||||
public async Task WebSocketsTransportSetsTransferFormat(TransferFormat transferFormat)
|
||||
{
|
||||
using (var server = await StartServer<Startup>())
|
||||
await using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.SignalR.Tests;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
|
||||
{
|
||||
public class RedisServerFixture<TStartup> : IAsyncLifetime, IDisposable
|
||||
public class RedisServerFixture<TStartup> : IAsyncLifetime
|
||||
where TStartup : class
|
||||
{
|
||||
public InProcessTestServer<TStartup> FirstServer { get; private set; }
|
||||
|
|
@ -37,13 +36,24 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
|
|||
Docker.Default.Start(_logger);
|
||||
}
|
||||
|
||||
public Task DisposeAsync()
|
||||
public async Task DisposeAsync()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
if (Docker.Default != null)
|
||||
{
|
||||
await FirstServer.DisposeAsync();
|
||||
await SecondServer.DisposeAsync();
|
||||
Docker.Default.Stop(_logger);
|
||||
_logToken.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
if (Docker.Default == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FirstServer = await StartServer();
|
||||
SecondServer = await StartServer();
|
||||
}
|
||||
|
|
@ -60,16 +70,5 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Docker.Default != null)
|
||||
{
|
||||
FirstServer.Dispose();
|
||||
SecondServer.Dispose();
|
||||
Docker.Default.Stop(_logger);
|
||||
_logToken.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue