Reenable logging for SSE tests (#3320)

This commit is contained in:
BrennanConroy 2018-11-19 09:44:47 -08:00 committed by GitHub
parent 4cbabea501
commit a5884d3ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 15 deletions

View File

@ -322,23 +322,31 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task SSEWontStartIfSuccessfulConnectionIsNotEstablished()
{
// TODO: Add logging https://github.com/aspnet/SignalR/issues/2879
var httpHandler = new TestHttpMessageHandler();
httpHandler.OnGet("/?id=00000000-0000-0000-0000-000000000000", (_, __) =>
bool ExpectedErrors(WriteContext writeContext)
{
return Task.FromResult(ResponseUtils.CreateResponse(HttpStatusCode.InternalServerError));
});
return writeContext.LoggerName == typeof(HttpConnection).FullName &&
writeContext.EventId.Name == "ErrorStartingTransport";
}
var sse = new ServerSentEventsTransport(new HttpClient(httpHandler));
using (StartVerifiableLog(expectedErrorsFilter: ExpectedErrors))
{
var httpHandler = new TestHttpMessageHandler();
await WithConnectionAsync(
CreateConnection(httpHandler, transport: sse),
async (connection) =>
httpHandler.OnGet("/?id=00000000-0000-0000-0000-000000000000", (_, __) =>
{
await Assert.ThrowsAsync<InvalidOperationException>(
() => connection.StartAsync(TransferFormat.Text).OrTimeout());
return Task.FromResult(ResponseUtils.CreateResponse(HttpStatusCode.InternalServerError));
});
var sse = new ServerSentEventsTransport(new HttpClient(httpHandler), LoggerFactory);
await WithConnectionAsync(
CreateConnection(httpHandler, loggerFactory: LoggerFactory, transport: sse),
async (connection) =>
{
await Assert.ThrowsAsync<InvalidOperationException>(
() => connection.StartAsync(TransferFormat.Text).OrTimeout());
});
}
}
[Fact]

View File

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Connections.Client.Internal;
using Microsoft.AspNetCore.SignalR.Tests;
using Microsoft.Extensions.Logging.Testing;
using Moq;
using Moq.Protected;
using Xunit;
@ -156,7 +157,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task SSETransportStopsWithErrorIfSendingMessageFails()
{
// TODO: Add logging https://github.com/aspnet/SignalR/issues/2879
bool ExpectedErrors(WriteContext writeContext)
{
return writeContext.LoggerName == typeof(ServerSentEventsTransport).FullName &&
writeContext.EventId.Name == "ErrorSending";
}
var eventStreamTcs = new TaskCompletionSource<object>();
var copyToAsyncTcs = new TaskCompletionSource<int>();
@ -185,8 +191,9 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
});
using (var httpClient = new HttpClient(mockHttpHandler.Object))
using (StartVerifiableLog(expectedErrorsFilter: ExpectedErrors))
{
var sseTransport = new ServerSentEventsTransport(httpClient);
var sseTransport = new ServerSentEventsTransport(httpClient, LoggerFactory);
await sseTransport.StartAsync(
new Uri("http://fakeuri.org"), TransferFormat.Text).OrTimeout();

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionSuffix>alpha1</VersionSuffix>
<JavaVersionPrefix>1.0.0</JavaVersionPrefix>
<JavaVersionPrefix>3.0.0</JavaVersionPrefix>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
<BuildNumber Condition="'$(BuildNumber)' == ''">t000</BuildNumber>