This commit is contained in:
John Luo 2017-08-16 19:30:36 -07:00
Родитель 17852e5217
Коммит dc8d1d0788
5 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -253,7 +253,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
Assert.Equal(FileLength.ToString(), contentLength.First());
Assert.Null(response.Headers.TransferEncodingChunked);
Assert.Equal(FileLength, response.Content.ReadAsByteArrayAsync().Result.Length);
Assert.Equal(FileLength, (await response.Content.ReadAsByteArrayAsync()).Length);
}
}

Просмотреть файл

@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Assert.Equal(200, (int)response.StatusCode);
Assert.False(response.Headers.TransferEncodingChunked.HasValue, "Chunked");
Assert.Equal(0, response.Content.Headers.ContentLength);
Assert.Equal(string.Empty, response.Content.ReadAsStringAsync().Result);
Assert.Equal(string.Empty, await response.Content.ReadAsStringAsync());
}
}

Просмотреть файл

@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
}
[ConditionalFact]
public void ResponseBody_WriteContentLengthNotEnoughWritten_Throws()
public async Task ResponseBody_WriteContentLengthNotEnoughWritten_Throws()
{
string address;
using (Utilities.CreateHttpServer(out address, httpContext =>
@ -131,7 +131,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
return httpContext.Response.Body.WriteAsync(new byte[5], 0, 5);
}))
{
Assert.Throws<AggregateException>(() => SendRequestAsync(address).Result);
await Assert.ThrowsAsync<HttpRequestException>(async () => await SendRequestAsync(address));
}
}

Просмотреть файл

@ -274,7 +274,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length");
Assert.Equal(FileLength.ToString(), contentLength.First());
Assert.Null(response.Headers.TransferEncodingChunked);
Assert.Equal(FileLength, response.Content.ReadAsByteArrayAsync().Result.Length);
Assert.Equal(FileLength, (await response.Content.ReadAsByteArrayAsync()).Length);
}
}

Просмотреть файл

@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
}
[ConditionalFact]
public void Server_AppException_ClientReset()
public async Task Server_AppException_ClientReset()
{
string address;
using (Utilities.CreateHttpServer(out address, httpContext =>
@ -144,11 +144,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
}))
{
Task<string> requestTask = SendRequestAsync(address);
Assert.Throws<AggregateException>(() => requestTask.Result);
await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask);
// Do it again to make sure the server didn't crash
requestTask = SendRequestAsync(address);
Assert.Throws<AggregateException>(() => requestTask.Result);
await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask);
}
}