コード例 #1
0
        public async Task ReadAsync()
        {
            byte[] bytesRet = Encoding.ASCII.GetBytes("Some random string");
            _mockStream.Setup(s => s.ReadAsync(
                                  It.IsAny <byte[]>(), 0, Constants.BufferSize, It.IsAny <CancellationToken>()))
            .Callback((byte[] arr, int offset, int count, CancellationToken token) =>
            {
                for (int i = 0; i < bytesRet.Length; i++)
                {
                    arr[i] = bytesRet[i];
                }
            })
            .Returns(Task.FromResult(bytesRet.Length));

            Assert.Equal(bytesRet, await _pipe.ReadAsync());
            _mockStream.VerifyAll();
        }
コード例 #2
0
 /// <inheritdoc />
 public Task <byte[]> ReadAsync(CancellationToken cancellationToken = default(CancellationToken))
 => _pipe.ReadAsync(cancellationToken);