one last try to get this test de-flaked (#227)

This commit is contained in:
Andrew Stanton-Nurse 2017-02-21 16:15:32 -08:00 committed by GitHub
parent 755ba7613e
commit f84362cc76
3 changed files with 4 additions and 5 deletions

View File

@ -198,7 +198,8 @@ namespace Microsoft.Extensions.WebSockets.Internal
{
if (State == WebSocketConnectionState.Closed)
{
throw new ObjectDisposedException(nameof(WebSocketConnection));
// Already closed
return;
}
else if (State == WebSocketConnectionState.Created)
{

View File

@ -123,7 +123,6 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
// Verify we can't restart the connection or send a message
await Assert.ThrowsAsync<ObjectDisposedException>(async () => await pair.ServerSocket.ExecuteAsync(f => { }));
await Assert.ThrowsAsync<ObjectDisposedException>(async () => await pair.ClientSocket.SendAsync(CreateTextFrame("Nope")));
await Assert.ThrowsAsync<ObjectDisposedException>(async () => await pair.ClientSocket.CloseAsync(new WebSocketCloseResult(WebSocketCloseStatus.NormalClosure)));
}
}

View File

@ -22,7 +22,7 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
var startTime = DateTime.UtcNow;
// Arrange
using (var pair = WebSocketPair.Create(
serverOptions: new WebSocketOptions().WithAllFramesPassedThrough().WithPingInterval(TimeSpan.FromMilliseconds(100)),
serverOptions: new WebSocketOptions().WithAllFramesPassedThrough().WithPingInterval(TimeSpan.FromMilliseconds(10)),
clientOptions: new WebSocketOptions().WithAllFramesPassedThrough()))
{
var client = pair.ClientSocket.ExecuteAndCaptureFramesAsync();
@ -47,8 +47,7 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
var str = Encoding.UTF8.GetString(f.Payload.ToArray());
// We can't verify the exact timestamp, but we can verify that it is a timestamp created after we started.
DateTime dt;
if (DateTime.TryParseExact(str, "O", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out dt))
if (DateTime.TryParseExact(str, "O", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var dt))
{
return dt >= startTime;
}