React to CoreFx byte[] slice

This commit is contained in:
BrennanConroy 2017-04-03 11:45:00 -07:00
parent d9faf17f5c
commit f6f0007c12
2 changed files with 6 additions and 6 deletions

View File

@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
var buffer = new ArraySegment<byte>(new byte[1024]); var buffer = new ArraySegment<byte>(new byte[1024]);
var result = await ws.ReceiveAsync(buffer, CancellationToken.None); var result = await ws.ReceiveAsync(buffer, CancellationToken.None);
Assert.Equal(bytes, buffer.Array.Slice(0, message.Length).ToArray()); Assert.Equal(bytes, buffer.Array.AsSpan().Slice(0, message.Length).ToArray());
await ws.CloseAsync(WebSocketCloseStatus.Empty, "", CancellationToken.None); await ws.CloseAsync(WebSocketCloseStatus.Empty, "", CancellationToken.None);
} }

View File

@ -64,13 +64,13 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
var result = await RunReceiveTest( var result = await RunReceiveTest(
producer: async (channel, cancellationToken) => producer: async (channel, cancellationToken) =>
{ {
await channel.WriteAsync(new byte[] { 0x02, 0x05 }.Slice()).OrTimeout(); await channel.WriteAsync(new byte[] { 0x02, 0x05 }.AsSpan()).OrTimeout();
await Task.Yield(); await Task.Yield();
await channel.WriteAsync(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF, 0xAB, 0x80, 0x05 }.Slice()).OrTimeout(); await channel.WriteAsync(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF, 0xAB, 0x80, 0x05 }.AsSpan()).OrTimeout();
await Task.Yield(); await Task.Yield();
await channel.WriteAsync(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }.Slice()).OrTimeout(); await channel.WriteAsync(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }.AsSpan()).OrTimeout();
await Task.Yield(); await Task.Yield();
await channel.WriteAsync(new byte[] { 0xAB }.Slice()).OrTimeout(); await channel.WriteAsync(new byte[] { 0xAB }.AsSpan()).OrTimeout();
await Task.Yield(); await Task.Yield();
}); });
@ -178,7 +178,7 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
var result = await RunReceiveTest( var result = await RunReceiveTest(
producer: async (channel, cancellationToken) => producer: async (channel, cancellationToken) =>
{ {
await channel.WriteAsync(rawFrame.Slice()).OrTimeout(); await channel.WriteAsync(rawFrame.AsSpan()).OrTimeout();
}); });
var frames = result.Received; var frames = result.Received;
Assert.Equal(1, frames.Count); Assert.Equal(1, frames.Count);