File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1
- namespace OpenMcdf . Tests ;
1
+ using System ;
2
+
3
+ namespace OpenMcdf . Tests ;
2
4
3
5
[ TestClass ]
4
6
public sealed class StreamTests
@@ -104,6 +106,22 @@ public void ReadSingleByte(Version version, int length)
104
106
StreamAssert . AreEqual ( expectedStream , actualStream ) ;
105
107
}
106
108
109
+ [ TestMethod ]
110
+ [ DataRow ( Version . V3 , 64 ) ] // Mini-stream
111
+ [ DataRow ( Version . V4 , 4096 ) ] // Regular stream
112
+ public void Seek ( Version version , int length )
113
+ {
114
+ string fileName = $ "TestStream_v{ ( int ) version } _{ length } .cfs";
115
+ using var rootStorage = RootStorage . OpenRead ( fileName ) ;
116
+ using Stream stream = rootStorage . OpenStream ( "TestStream" ) ;
117
+
118
+ stream . Seek ( 0 , SeekOrigin . Begin ) ;
119
+ Assert . ThrowsException < IOException > ( ( ) => stream . Seek ( - 1 , SeekOrigin . Begin ) ) ;
120
+ Assert . ThrowsException < IOException > ( ( ) => stream . Seek ( - 1 , SeekOrigin . Current ) ) ;
121
+ Assert . ThrowsException < IOException > ( ( ) => stream . Seek ( length + 1 , SeekOrigin . End ) ) ;
122
+ Assert . ThrowsException < ArgumentException > ( ( ) => stream . Seek ( length , ( SeekOrigin ) 3 ) ) ;
123
+ }
124
+
107
125
[ TestMethod ]
108
126
[ DataRow ( Version . V3 , 0 ) ]
109
127
[ DataRow ( Version . V3 , 63 ) ]
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public static void ThrowIfNotWritable(this Stream stream)
37
37
throw new NotSupportedException ( "Stream does not support writing." ) ;
38
38
}
39
39
40
- public static void ThrowSeekBeforeOrigin ( ) => throw new IOException ( "Seek before origin ." ) ;
40
+ public static void ThrowSeekBeforeOrigin ( ) => throw new IOException ( "An attempt was made to move the position before the beginning of the stream ." ) ;
41
41
42
42
public static void ThrowIfNameIsInvalid ( string value )
43
43
{
You can’t perform that action at this time.
0 commit comments