Test cleanup and fixes (#18666)
This commit is contained in:
parent
dedb295650
commit
358c84c4d2
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -85,7 +86,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CheckFixedMessage(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -124,7 +125,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
|
||||
var protocol = HubProtocols["json"];
|
||||
using (StartServer<Startup>(out var server, ExpectedError))
|
||||
using (var server = await StartServer<Startup>(ExpectedError))
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -154,7 +155,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ClientCanConnectToServerWithLowerMinimumProtocol()
|
||||
{
|
||||
var protocol = HubProtocols["json"];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -184,7 +185,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanSendAndReceiveMessage(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
|
|
@ -213,7 +214,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanSendNull(string protocolName)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.LongPolling, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -242,7 +243,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStopAndStartConnection(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
|
|
@ -274,7 +275,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanAccessConnectionIdFromHubConnection(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -309,7 +310,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStartConnectionFromClosedEvent(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<HubConnectionTests>();
|
||||
const string originalMessage = "SignalR";
|
||||
|
|
@ -371,7 +372,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task MethodsAreCaseInsensitive(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
|
|
@ -401,7 +402,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanInvokeFromOnHandler(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
|
||||
|
|
@ -441,7 +442,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncCoreTest(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -476,7 +477,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamToHubWithIAsyncEnumerableMethodArg(string protocolName)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.WebSockets, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -522,7 +523,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncTest(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -557,7 +558,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -594,7 +595,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncCanBeCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -642,7 +643,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -678,7 +679,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanInvokeClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
const string originalMessage = "SignalR";
|
||||
|
||||
|
|
@ -712,7 +713,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task InvokeNonExistantClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
var closeTcs = new TaskCompletionSource<object>();
|
||||
|
|
@ -754,7 +755,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -784,7 +785,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamToAndFromClientInSameInvocation(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -821,7 +822,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanStreamToServerWithIAsyncEnumerable(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -868,7 +869,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanCancelIAsyncEnumerableClientToServerUpload(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -921,7 +922,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamAsyncCanBeCanceledThroughGetAsyncEnumerator(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -962,7 +963,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task CanCloseStreamMethodEarly(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1003,7 +1004,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task StreamDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path)
|
||||
{
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1038,7 +1039,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
|
||||
var protocol = HubProtocols[protocolName];
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1066,7 +1067,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfHubMethodCannotBeResolved(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1093,7 +1094,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfHubMethodCannotBeResolvedAndArgumentsPassedIn(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1120,7 +1121,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnHubMethodArgumentCountMismatch(string hubProtocolName)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.LongPolling, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1147,7 +1148,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnHubMethodArgumentTypeMismatch(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1174,7 +1175,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfStreamingHubMethodCannotBeResolved(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1202,7 +1203,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnStreamingHubMethodArgumentCountMismatch(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1230,7 +1231,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionOnStreamingHubMethodArgumentTypeMismatch(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1258,7 +1259,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfNonStreamMethodInvokedWithStreamAsync(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1285,7 +1286,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfStreamMethodInvokedWithInvoke(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1312,7 +1313,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
public async Task ServerThrowsHubExceptionIfBuildingAsyncEnumeratorIsNotPossible(string hubProtocolName, HttpTransportType transportType, string hubPath)
|
||||
{
|
||||
var hubProtocol = HubProtocols[hubProtocolName];
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
try
|
||||
|
|
@ -1341,7 +1342,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
var hubProtocol = HubProtocols.First().Value;
|
||||
var transportType = TransportTypes().First().Cast<HttpTransportType>().First();
|
||||
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, hubPath, transportType, hubProtocol, LoggerFactory);
|
||||
await connection.StartAsync().OrTimeout();
|
||||
|
|
@ -1358,7 +1359,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientCanUseJwtBearerTokenForAuthentication(HttpTransportType transportType)
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
async Task<string> AccessTokenProvider()
|
||||
{
|
||||
|
|
@ -1401,7 +1402,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
return writeContext.Exception is HttpRequestException;
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1423,7 +1424,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientCanUseJwtBearerTokenForAuthenticationWhenRedirected(HttpTransportType transportType)
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1451,7 +1452,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientCanSendHeaders(HttpTransportType transportType)
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1482,7 +1483,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserAgentIsSet()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1524,7 +1525,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserAgentCanBeCleared()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1559,7 +1560,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserAgentCanBeSet()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1595,7 +1596,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketOptionsAreApplied()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
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();
|
||||
|
|
@ -1626,10 +1627,10 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact(Skip = "Returning object from Hub method not support by System.Text.Json yet")]
|
||||
[Fact]
|
||||
public async Task CheckHttpConnectionFeatures()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1639,11 +1640,11 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
{
|
||||
await hubConnection.StartAsync().OrTimeout();
|
||||
|
||||
var features = await hubConnection.InvokeAsync<object[]>(nameof(TestHub.GetIHttpConnectionFeatureProperties)).OrTimeout();
|
||||
var localPort = (long)features[0];
|
||||
var remotePort = (long)features[1];
|
||||
var localIP = (string)features[2];
|
||||
var remoteIP = (string)features[3];
|
||||
var features = await hubConnection.InvokeAsync<JsonElement[]>(nameof(TestHub.GetIHttpConnectionFeatureProperties)).OrTimeout();
|
||||
var localPort = features[0].GetInt64();
|
||||
var remotePort = features[1].GetInt64();
|
||||
var localIP = features[2].GetString();
|
||||
var remoteIP = features[3].GetString();
|
||||
|
||||
Assert.True(localPort > 0L);
|
||||
Assert.True(remotePort > 0L);
|
||||
|
|
@ -1665,7 +1666,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UserIdProviderCanAccessHttpContext()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1696,7 +1697,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task NegotiationSkipsServerSentEventsWhenUsingBinaryProtocol()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var hubConnectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1726,7 +1727,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Fact]
|
||||
public async Task StopCausesPollToReturnImmediately()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
PollTrackingMessageHandler pollTracker = null;
|
||||
var hubConnection = new HubConnectionBuilder()
|
||||
|
|
@ -1774,7 +1775,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
writeContext.EventId.Name == "ReconnectingWithError";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = CreateHubConnection(
|
||||
server.Url,
|
||||
|
|
@ -1836,7 +1837,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
writeContext.EventId.Name == "ReconnectingWithError";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var connection = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -1896,7 +1897,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
writeContext.EventId.Name == "ReconnectingWithError";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
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 (StartServer<VersionStartup>(out var server))
|
||||
using (var server = await StartServer<VersionStartup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
|
||||
public async Task ClientUsingOldCallWithNewProtocol(HttpTransportType transportType)
|
||||
{
|
||||
using (StartServer<VersionStartup>(out var server))
|
||||
using (var server = await StartServer<VersionStartup>())
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
[MemberData(nameof(TransportTypes))]
|
||||
public async Task ClientUsingNewCallWithNewProtocol(HttpTransportType transportType)
|
||||
{
|
||||
using (StartServer<VersionStartup>(out var server))
|
||||
using (var server = await StartServer<VersionStartup>())
|
||||
{
|
||||
var httpConnectionFactory = new HttpConnectionFactory(
|
||||
Options.Create(new HttpConnectionOptions
|
||||
|
|
@ -167,7 +167,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
return writeContext.LoggerName == typeof(HubConnection).FullName;
|
||||
}
|
||||
|
||||
using (StartServer<VersionStartup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<VersionStartup>(ExpectedErrors))
|
||||
{
|
||||
var connectionBuilder = new HubConnectionBuilder()
|
||||
.WithLoggerFactory(LoggerFactory)
|
||||
|
|
|
|||
|
|
@ -1167,6 +1167,18 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
await request1.OrTimeout();
|
||||
|
||||
Assert.Equal(StatusCodes.Status204NoContent, context1.Response.StatusCode);
|
||||
|
||||
count = 0;
|
||||
// Wait until the second request has started internally
|
||||
while (connection.TransportTask.IsCompleted && count < 50)
|
||||
{
|
||||
count++;
|
||||
await Task.Delay(15);
|
||||
}
|
||||
if (count == 50)
|
||||
{
|
||||
Assert.True(false, "Poll took too long to start");
|
||||
}
|
||||
Assert.Equal(HttpConnectionStatus.Active, connection.Status);
|
||||
|
||||
Assert.False(request2.IsCompleted);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Tests
|
||||
|
|
@ -35,28 +36,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
};
|
||||
}
|
||||
|
||||
public IDisposable StartServer<T>(out InProcessTestServer<T> testServer, Func<WriteContext, bool> expectedErrorsFilter = null) where T : class
|
||||
public Task<InProcessTestServer<T>> StartServer<T>(Func<WriteContext, bool> expectedErrorsFilter = null) where T : class
|
||||
{
|
||||
var disposable = base.StartVerifiableLog(ResolveExpectedErrorsFilter(expectedErrorsFilter));
|
||||
testServer = new InProcessTestServer<T>(LoggerFactory);
|
||||
return new MultiDisposable(testServer, disposable);
|
||||
}
|
||||
|
||||
private class MultiDisposable : IDisposable
|
||||
{
|
||||
List<IDisposable> _disposables;
|
||||
public MultiDisposable(params IDisposable[] disposables)
|
||||
{
|
||||
_disposables = new List<IDisposable>(disposables);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var disposable in _disposables)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
return InProcessTestServer<T>.StartServer(LoggerFactory, disposable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
|
|
@ -35,6 +36,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
private IWebHost _host;
|
||||
private IHostApplicationLifetime _lifetime;
|
||||
private readonly IDisposable _logToken;
|
||||
private readonly IDisposable _extraDisposable;
|
||||
|
||||
private readonly LogSinkProvider _logSinkProvider;
|
||||
private string _url;
|
||||
|
|
@ -49,12 +51,20 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
public override string Url => _url;
|
||||
|
||||
public InProcessTestServer() : this(loggerFactory: null)
|
||||
public static async Task<InProcessTestServer<TStartup>> StartServer(ILoggerFactory loggerFactory, IDisposable disposable = null)
|
||||
{
|
||||
var server = new InProcessTestServer<TStartup>(loggerFactory, disposable);
|
||||
await server.StartServerInner();
|
||||
return server;
|
||||
}
|
||||
|
||||
private InProcessTestServer() : this(loggerFactory: null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public InProcessTestServer(ILoggerFactory loggerFactory)
|
||||
private InProcessTestServer(ILoggerFactory loggerFactory, IDisposable disposable)
|
||||
{
|
||||
_extraDisposable = disposable;
|
||||
_logSinkProvider = new LogSinkProvider();
|
||||
|
||||
if (loggerFactory == null)
|
||||
|
|
@ -71,11 +81,9 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
_loggerFactory = new WrappingLoggerFactory(_loggerFactory);
|
||||
_loggerFactory.AddProvider(_logSinkProvider);
|
||||
_logger = _loggerFactory.CreateLogger<InProcessTestServer<TStartup>>();
|
||||
|
||||
StartServer();
|
||||
}
|
||||
|
||||
private void StartServer()
|
||||
private async Task StartServerInner()
|
||||
{
|
||||
// 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";
|
||||
|
|
@ -90,27 +98,24 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.Build();
|
||||
|
||||
var t = Task.Run(() => _host.Start());
|
||||
_logger.LogInformation("Starting test server...");
|
||||
_lifetime = _host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
|
||||
// This only happens once per fixture, so we can afford to wait a little bit on it.
|
||||
if (!_lifetime.ApplicationStarted.WaitHandle.WaitOne(TimeSpan.FromSeconds(20)))
|
||||
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
||||
try
|
||||
{
|
||||
await _host.StartAsync(cts.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// t probably faulted
|
||||
if (t.IsFaulted)
|
||||
{
|
||||
throw t.Exception.InnerException;
|
||||
}
|
||||
|
||||
var logs = _logSinkProvider.GetLogs();
|
||||
throw new TimeoutException($"Timed out waiting for application to start.{Environment.NewLine}Startup Logs:{Environment.NewLine}{RenderLogs(logs)}");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Test Server started");
|
||||
|
||||
// Get the URL from the server
|
||||
_url = _host.ServerFeatures.Get<IServerAddressesFeature>().Addresses.Single();
|
||||
|
||||
_lifetime = _host.Services.GetRequiredService<IHostApplicationLifetime>();
|
||||
_lifetime.ApplicationStopped.Register(() =>
|
||||
{
|
||||
_logger.LogInformation("Test server shut down");
|
||||
|
|
@ -138,6 +143,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
public override void Dispose()
|
||||
{
|
||||
_extraDisposable?.Dispose();
|
||||
_logger.LogInformation("Shutting down test server");
|
||||
_host.Dispose();
|
||||
_loggerFactory.Dispose();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[Fact]
|
||||
public async Task CanStartAndStopConnectionUsingDefaultTransport()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
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 (StartServer<Startup>(out var server, expectedErrorsFilter: ExpectedErrors))
|
||||
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 (StartServer<Startup>(out var server))
|
||||
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 (StartServer<Startup>(out var server))
|
||||
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 (StartServer<Startup>(out var server))
|
||||
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 (StartServer<Startup>(out var server))
|
||||
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 (StartServer<Startup>(out var server))
|
||||
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 (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
public async Task ConnectionCanSendAndReceiveDifferentMessageSizesWebSocketsTransport(int length)
|
||||
{
|
||||
var message = new string('A', length);
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorStartingTransport";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -419,7 +419,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -455,7 +455,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -525,7 +525,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
private async Task ServerClosesConnectionWithErrorIfHubCannotBeCreated(HttpTransportType transportType)
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -590,7 +590,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -629,7 +629,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -668,7 +668,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
@ -715,7 +715,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
writeContext.EventId.Name == "ErrorWithNegotiation";
|
||||
}
|
||||
|
||||
using (StartServer<Startup>(out var server, ExpectedErrors))
|
||||
using (var server = await StartServer<Startup>(ExpectedErrors))
|
||||
{
|
||||
var logger = LoggerFactory.CreateLogger<EndToEndTests>();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.AspNetCore.Http.Connections.Client;
|
||||
using Xunit;
|
||||
using Constants = Microsoft.AspNetCore.Http.Connections.Client.Internal.Constants;
|
||||
|
||||
|
|
@ -15,18 +12,43 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
public class UserAgentHeaderTest
|
||||
{
|
||||
[Theory]
|
||||
[MemberData(nameof(UserAgents))]
|
||||
public void UserAgentHeaderIsCorrect(Version version, string detailedVersion, string os, string runtime, string runtimeVersion, string expected)
|
||||
[MemberData(nameof(UserAgentTestDataNames))]
|
||||
public void UserAgentHeaderIsCorrect(string testDataName)
|
||||
{
|
||||
Assert.Equal(expected, Constants.ConstructUserAgent(version, detailedVersion, os, runtime, runtimeVersion));
|
||||
var testData = UserAgents[testDataName];
|
||||
Assert.Equal(testData.Expected, Constants.ConstructUserAgent(testData.Version, testData.DetailedVersion, testData.Os, testData.Runtime, testData.RuntimeVersion));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> UserAgents()
|
||||
public static Dictionary<string, UserAgentTestData> UserAgents => new[]
|
||||
{
|
||||
yield return new object[] { new Version(1, 4), "1.4.3-preview9", "Windows NT", ".NET", ".NET 4.8.7", "Microsoft SignalR/1.4 (1.4.3-preview9; Windows NT; .NET; .NET 4.8.7)" };
|
||||
yield return new object[] { new Version(3, 1), "3.1.0", "", ".NET", ".NET 4.8.9", "Microsoft SignalR/3.1 (3.1.0; Unknown OS; .NET; .NET 4.8.9)" };
|
||||
yield return new object[] { new Version(3, 1), "3.1.0", "", ".NET", "", "Microsoft SignalR/3.1 (3.1.0; Unknown OS; .NET; Unknown Runtime Version)" };
|
||||
yield return new object[] { new Version(3, 1), "", "Linux", ".NET", ".NET 4.5.1", "Microsoft SignalR/3.1 (Unknown Version; Linux; .NET; .NET 4.5.1)" };
|
||||
new UserAgentTestData("FullInfo", new Version(1, 4), "1.4.3-preview9", "Windows NT", ".NET", ".NET 4.8.7", "Microsoft SignalR/1.4 (1.4.3-preview9; Windows NT; .NET; .NET 4.8.7)"),
|
||||
new UserAgentTestData("EmptyOs", new Version(3, 1), "3.1.0", "", ".NET", ".NET 4.8.9", "Microsoft SignalR/3.1 (3.1.0; Unknown OS; .NET; .NET 4.8.9)"),
|
||||
new UserAgentTestData("EmptyRuntimeVersion", new Version(3, 1), "3.1.0", "", ".NET", "", "Microsoft SignalR/3.1 (3.1.0; Unknown OS; .NET; Unknown Runtime Version)"),
|
||||
new UserAgentTestData("EmptyDetailedVersion", new Version(3, 1), "", "Linux", ".NET", ".NET 4.5.1", "Microsoft SignalR/3.1 (Unknown Version; Linux; .NET; .NET 4.5.1)"),
|
||||
}.ToDictionary(t => t.Name);
|
||||
|
||||
public static IEnumerable<object[]> UserAgentTestDataNames => UserAgents.Keys.Select(name => new object[] { name });
|
||||
|
||||
public class UserAgentTestData
|
||||
{
|
||||
public string Name { get; }
|
||||
public Version Version { get; }
|
||||
public string DetailedVersion { get; }
|
||||
public string Os { get; }
|
||||
public string Runtime { get; }
|
||||
public string RuntimeVersion { get; }
|
||||
public string Expected { get; }
|
||||
|
||||
public UserAgentTestData(string name, Version version, string detailedVersion, string os, string runtime, string runtimeVersion, string expected)
|
||||
{
|
||||
Name = name;
|
||||
Version = version;
|
||||
DetailedVersion = detailedVersion;
|
||||
Os = os;
|
||||
Runtime = runtime;
|
||||
RuntimeVersion = runtimeVersion;
|
||||
Expected = expected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportStopsSendAndReceiveLoopsWhenTransportIsStopped()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/echo"),
|
||||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportSendsUserAgent()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/httpheader"),
|
||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportSendsXRequestedWithHeader()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/httpheader"),
|
||||
|
|
@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[WebSocketsSupportedCondition]
|
||||
public async Task WebSocketsTransportStopsWhenConnectionChannelClosed()
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
await webSocketsTransport.StartAsync(new Uri(server.WebSocketsUrl + "/echo"),
|
||||
|
|
@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[InlineData(TransferFormat.Binary)]
|
||||
public async Task WebSocketsTransportStopsWhenConnectionClosedByTheServer(TransferFormat transferFormat)
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
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);
|
||||
|
|
@ -155,7 +155,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
[InlineData(TransferFormat.Binary)]
|
||||
public async Task WebSocketsTransportSetsTransferFormat(TransferFormat transferFormat)
|
||||
{
|
||||
using (StartServer<Startup>(out var server))
|
||||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: LoggerFactory, accessTokenProvider: null);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,15 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR.Tests;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Testing;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
|
||||
{
|
||||
public class RedisServerFixture<TStartup> : IDisposable
|
||||
public class RedisServerFixture<TStartup> : IAsyncLifetime, IDisposable
|
||||
where TStartup : class
|
||||
{
|
||||
public InProcessTestServer<TStartup> FirstServer { get; private set; }
|
||||
|
|
@ -32,16 +34,24 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
|
|||
_logger = _loggerFactory.CreateLogger<RedisServerFixture<TStartup>>();
|
||||
|
||||
Docker.Default.Start(_logger);
|
||||
|
||||
FirstServer = StartServer();
|
||||
SecondServer = StartServer();
|
||||
}
|
||||
|
||||
private InProcessTestServer<TStartup> StartServer()
|
||||
public Task DisposeAsync()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
FirstServer = await StartServer();
|
||||
SecondServer = await StartServer();
|
||||
}
|
||||
|
||||
private async Task<InProcessTestServer<TStartup>> StartServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new InProcessTestServer<TStartup>(_loggerFactory);
|
||||
return await InProcessTestServer<TStartup>.StartServer(_loggerFactory);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue