@@ -238,6 +238,41 @@ public void TestVersioning()
238
238
version . ShouldEqual ( informationalVersion . InformationalVersion + ".0" ) ;
239
239
}
240
240
241
+ [ TestMethod ]
242
+ public void TestShortFlush ( )
243
+ {
244
+ var command = Command . Run ( "SampleCommand" , "shortflush" , "a" ) ;
245
+ var readCommand = command . StandardOutput . ReadBlockAsync ( new char [ 1 ] , 0 , 1 ) ;
246
+ //var readCommand = command.StandardOutput.BaseStream.ReadAsync(new byte[1], 0, 1);
247
+ readCommand . Wait ( TimeSpan . FromSeconds ( 5 ) ) . ShouldEqual ( true ) ;
248
+
249
+ command . StandardInput . Close ( ) ;
250
+ command . Task . Wait ( TimeSpan . FromSeconds ( 5 ) ) . ShouldEqual ( true ) ;
251
+ }
252
+
253
+ [ TestMethod ]
254
+ public void TestAutoFlush ( )
255
+ {
256
+ var command = Command . Run ( "SampleCommand" , "echo" , "--per-char" ) ;
257
+ command . StandardInput . AutoFlush . ShouldEqual ( true ) ;
258
+ command . StandardInput . Write ( 'a' ) ;
259
+
260
+ var buffer = new char [ 1 ] ;
261
+ var asyncRead = command . StandardOutput . ReadBlockAsync ( buffer , 0 , 1 ) ;
262
+ asyncRead . Wait ( TimeSpan . FromSeconds ( 3 ) ) . ShouldEqual ( true ) ;
263
+ buffer [ 0 ] . ShouldEqual ( 'a' ) ;
264
+
265
+ command . StandardInput . AutoFlush = false ;
266
+ command . StandardInput . Write ( 'b' ) ;
267
+ asyncRead = command . StandardOutput . ReadBlockAsync ( buffer , 0 , 1 ) ;
268
+ asyncRead . Wait ( TimeSpan . FromSeconds ( .01 ) ) . ShouldEqual ( false ) ;
269
+ command . StandardInput . Flush ( ) ;
270
+ asyncRead . Wait ( TimeSpan . FromSeconds ( 3 ) ) . ShouldEqual ( true ) ;
271
+ buffer [ 0 ] . ShouldEqual ( 'b' ) ;
272
+
273
+ command . StandardInput . Close ( ) ;
274
+ }
275
+
241
276
[ TestMethod ]
242
277
public void TestErrorEcho ( )
243
278
{
0 commit comments