22
33namespace DotNext . IO ;
44
5- public sealed class FixedLengthStreamTests : Test
5+ public sealed class MemorySegmentStreamTests : Test
66{
77 private static async Task ReadWriteStringUsingEncodingAsync ( string value , Encoding encoding , LengthFormat lengthEnc )
88 {
99 Memory < byte > buffer = new byte [ 16 ] ;
10- await using var ms = new FixedLengthStream ( new byte [ 1024 ] ) ;
10+ await using var ms = new MemorySegmentStream ( new byte [ 1024 ] ) ;
1111 await ms . EncodeAsync ( value . AsMemory ( ) , encoding , lengthEnc , buffer ) ;
1212 ms . Position = 0 ;
1313 using var result = await ms . DecodeAsync ( encoding , lengthEnc , buffer ) ;
@@ -36,7 +36,7 @@ public static async Task ReadWriteStringAsync(LengthFormat lengthEnc)
3636 [ InlineData ( true ) ]
3737 public static void Overflow ( bool skipOnOverflow )
3838 {
39- using var stream = new FixedLengthStream ( new byte [ 128 ] ) { SkipOnOverflow = skipOnOverflow } ;
39+ using var stream = new MemorySegmentStream ( new byte [ 128 ] ) { SkipOnOverflow = skipOnOverflow } ;
4040 ReadOnlyMemory < byte > dataToWrite = RandomBytes ( 256 ) ;
4141
4242 if ( skipOnOverflow )
@@ -56,7 +56,7 @@ public static void ReadWrite()
5656 {
5757 const int bufferSize = 128 ;
5858 Memory < byte > buffer = new byte [ bufferSize ] ;
59- using var stream = new FixedLengthStream ( buffer ) ;
59+ using var stream = new MemorySegmentStream ( buffer ) ;
6060 True ( stream . ConsumedSpan . IsEmpty ) ;
6161 False ( stream . RemainingSpan . IsEmpty ) ;
6262
@@ -77,7 +77,7 @@ public static async Task ReadWriteAsync()
7777 {
7878 const int bufferSize = 128 ;
7979 Memory < byte > buffer = new byte [ bufferSize ] ;
80- await using var stream = new FixedLengthStream ( buffer ) ;
80+ await using var stream = new MemorySegmentStream ( buffer ) ;
8181 True ( stream . ConsumedSpan . IsEmpty ) ;
8282 False ( stream . RemainingSpan . IsEmpty ) ;
8383
@@ -98,7 +98,7 @@ public static void Truncate()
9898 {
9999 const int bufferSize = 128 ;
100100 Memory < byte > buffer = new byte [ bufferSize ] ;
101- using var stream = new FixedLengthStream ( buffer ) ;
101+ using var stream = new MemorySegmentStream ( buffer ) ;
102102
103103 ReadOnlySpan < byte > dataToWrite = RandomBytes ( bufferSize ) ;
104104 stream . Write ( dataToWrite ) ;
@@ -114,7 +114,7 @@ public static void SetInvalidLength()
114114 {
115115 const int bufferSize = 128 ;
116116 Memory < byte > buffer = new byte [ bufferSize ] ;
117- using var stream = new FixedLengthStream ( buffer ) ;
117+ using var stream = new MemorySegmentStream ( buffer ) ;
118118
119119 Throws < ArgumentOutOfRangeException > ( ( ) => stream . SetLength ( - 1L ) ) ;
120120 Throws < IOException > ( ( ) => stream . SetLength ( bufferSize + 1 ) ) ;
0 commit comments