예제 #1
0
    public async Task UsePipeWriter_WebSocket()
    {
        var expectedBuffer = new byte[] { 4, 5, 6 };
        var webSocket      = new MockWebSocket();
        var pipeWriter     = webSocket.UsePipeWriter(cancellationToken: this.TimeoutToken);
        await pipeWriter.WriteAsync(expectedBuffer, this.TimeoutToken);

        pipeWriter.Complete();
        await pipeWriter.WaitForReaderCompletionAsync();

        var message = webSocket.WrittenQueue.Dequeue();

        Assert.Equal(expectedBuffer, message.Buffer.ToArray());
    }
예제 #2
0
    public async Task UsePipeWriter_WebSocket()
    {
        var expectedBuffer = new byte[] { 4, 5, 6 };
        var webSocket      = new MockWebSocket();
        var pipeWriter     = webSocket.UsePipeWriter(cancellationToken: this.TimeoutToken);
        await pipeWriter.WriteAsync(expectedBuffer, this.TimeoutToken);

        pipeWriter.Complete();
#pragma warning disable CS0618 // Type or member is obsolete
        await pipeWriter.WaitForReaderCompletionAsync();

#pragma warning restore CS0618 // Type or member is obsolete
        var message = webSocket.WrittenQueue.Dequeue();
        Assert.Equal(expectedBuffer, message.Buffer.ToArray());
    }