Repository: dotnet/runtime
File: src/libraries/System.IO.Pipelines/tests/StreamPipeReaderTests.cs (C#)

Code before:
            reader.Complete();
        }

        [Fact]
        public async Task ReadAsyncAfterReceivingCompletedReadResultDoesNotThrow()
        {
            byte[] helloBytes = "Hello World"u8.ToArray();
            var stream = new MemoryStream(helloBytes);
            PipeReader reader = PipeReader.Create(stream);
            ReadResult readResult = await reader.ReadAsync();
            Assert.Equal(helloBytes.Length, readResult.Buffer.Length);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.Buffer.IsEmpty);
            Assert.True(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);
            reader.Complete();
        }

        [Fact]
        public async Task ReadAsyncAfterReceivingCompletedReadResultAndResetingStreamPositionWorks()
        {
            byte[] helloBytes = "Hello World"u8.ToArray();
            var stream = new MemoryStream(helloBytes);
            PipeReader reader = PipeReader.Create(stream);
            ReadResult readResult = await reader.ReadAsync();
            Assert.Equal(helloBytes, readResult.Buffer.ToArray());
            Assert.False(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.IsCompleted);

            // Reset the stream position to the beginning
            stream.Position = 0;

            readResult = await reader.ReadAsync();
            Assert.Equal(helloBytes, readResult.Buffer.ToArray());
            Assert.False(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.IsCompleted);
            reader.Complete();
        }


Review comment (suggestion):
The method name contains a spelling error: 'Reseting' should be 'Resetting'.
```suggestion
        public async Task ReadAsyncAfterReceivingCompletedReadResultAndResettingStreamPositionWorks()
```

Code after:
            reader.Complete();
        }

        [Fact]
        public async Task ReadAsyncAfterReceivingCompletedReadResultDoesNotThrow()
        {
            byte[] helloBytes = "Hello World"u8.ToArray();
            var stream = new MemoryStream(helloBytes);
            PipeReader reader = PipeReader.Create(stream);
            ReadResult readResult = await reader.ReadAsync();
            Assert.Equal(helloBytes.Length, readResult.Buffer.Length);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.Buffer.IsEmpty);
            Assert.True(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);
            reader.Complete();
        }

        [Fact]
        public async Task ReadAsyncAfterReceivingCompletedReadResultAndResettingStreamPositionWorks()
        {
            byte[] helloBytes = "Hello World"u8.ToArray();
            var stream = new MemoryStream(helloBytes);
            PipeReader reader = PipeReader.Create(stream);
            ReadResult readResult = await reader.ReadAsync();
            Assert.Equal(helloBytes, readResult.Buffer.ToArray());
            Assert.False(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.IsCompleted);

            // Reset the stream position to the beginning
            stream.Position = 0;

            readResult = await reader.ReadAsync();
            Assert.Equal(helloBytes, readResult.Buffer.ToArray());
            Assert.False(readResult.IsCompleted);
            reader.AdvanceTo(readResult.Buffer.End);

            readResult = await reader.ReadAsync();
            Assert.True(readResult.IsCompleted);
            reader.Complete();
        }