React to CoreFx byte[] slice
This commit is contained in:
parent
d9faf17f5c
commit
f6f0007c12
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue