WrappedStream.SetLength C# (CSharp) Méthode

SetLength() public méthode

public SetLength ( long value ) : void
value long
Résultat void
    public override void SetLength(long value) { _baseStream.SetLength(value); }

Usage Example

Exemple #1
0
        public async Task Parameterized_Methods_Are_Properly_Wrapped()
        {
            var strm = Substitute.For <Stream>();

            strm.CanRead.Returns(true);
            strm.CanWrite.Returns(true);
            using (var wrprstrm = new WrappedStream(strm, false))
            {
                wrprstrm.Seek(0, SeekOrigin.Current);
                strm.Received(1).Seek(0, SeekOrigin.Current);

                wrprstrm.SetLength(10);
                strm.Received(1).SetLength(10);

                var arrByte = new byte[5];
                wrprstrm.Read(arrByte, 0, arrByte.Length);
                strm.Received(1).Read(arrByte, 0, arrByte.Length);

                wrprstrm.Write(arrByte, 0, arrByte.Length);
                strm.Received(1).Write(arrByte, 0, arrByte.Length);

                var anotherStrm = new MemoryStream();
                await wrprstrm.CopyToAsync(anotherStrm, 1, CancellationToken.None).ConfigureAwait(false);

                await strm.Received(1).CopyToAsync(anotherStrm, 1, CancellationToken.None).ConfigureAwait(false);

                await wrprstrm.FlushAsync(CancellationToken.None).ConfigureAwait(false);

                await strm.Received(1).FlushAsync(CancellationToken.None).ConfigureAwait(false);

                await wrprstrm.WriteAsync(arrByte, 1, arrByte.Length, CancellationToken.None).ConfigureAwait(false);

                await strm.Received(1)
                .WriteAsync(arrByte, 1, arrByte.Length, CancellationToken.None)
                .ConfigureAwait(false);

                await wrprstrm.ReadAsync(arrByte, 1, arrByte.Length, CancellationToken.None).ConfigureAwait(false);

                await strm.Received(1)
                .ReadAsync(arrByte, 1, arrByte.Length, CancellationToken.None)
                .ConfigureAwait(false);

                wrprstrm.WriteByte(20);
                strm.Received(1).WriteByte(20);

                var _  = wrprstrm.Equals(null);
                var __ = strm.Received(1).Equals(null);
            }
        }
All Usage Examples Of WrappedStream::SetLength