@@ -10,14 +10,13 @@ public class ConsoleTests
1010 public async Task QuitSucceeds ( )
1111 {
1212 var psi = GlobalSetup . CreateRunProcess ( ) ;
13-
1413 using var proc = Process . Start ( psi ) ;
1514
1615 await proc . StandardInput . WriteLineAsync ( "quit" ) . ConfigureAwait ( false ) ;
16+
1717 await proc . StandardInput . FlushAsync ( ) . ConfigureAwait ( false ) ;
1818
1919 var ct = TestContext . Current . Execution . CancellationToken ;
20-
2120 await proc . WaitForExitAsync ( ct ) . ConfigureAwait ( false ) ;
2221
2322 await Assert . That ( proc . ExitCode ) . IsEqualTo ( 0 ) ;
@@ -27,15 +26,14 @@ public async Task QuitSucceeds()
2726 public async Task HelpOutputExists ( )
2827 {
2928 var psi = GlobalSetup . CreateRunProcess ( ) ;
30-
3129 using var proc = Process . Start ( psi ) ;
3230
33- var output = new StringBuilder ( ) ;
34-
3531 await proc . StandardInput . WriteLineAsync ( "--help" ) . ConfigureAwait ( false ) ;
32+
3633 await proc . StandardInput . FlushAsync ( ) . ConfigureAwait ( false ) ;
3734 proc . StandardInput . Close ( ) ;
3835
36+ var output = new StringBuilder ( ) ;
3937 proc . OutputDataReceived += ( _ , args ) =>
4038 {
4139 if ( args . Data is not null )
@@ -47,14 +45,14 @@ public async Task HelpOutputExists()
4745 proc . BeginOutputReadLine ( ) ;
4846
4947 var ct = TestContext . Current . Execution . CancellationToken ;
50-
5148 await proc . WaitForExitAsync ( ct ) . ConfigureAwait ( false ) ;
5249
5350 await Assert . That ( output . ToString ( ) )
5451 . Contains ( "<input> The input file to convert" )
5552 . And . Contains ( "-f, --format <f> Format for the converted output file." )
5653 . And . Contains ( "-o, --output <o> Output path for the converted file." )
57- . And . Contains ( "q, quit Quit the application." ) ;
54+ . And . Contains ( "q, quit Quit the application." )
55+ . And . Contains ( "-?, -h, --help Show help and usage information" ) ;
5856 }
5957
6058 [ Test ]
@@ -65,15 +63,14 @@ await Assert.That(output.ToString())
6563 public async Task ErrorOutputs ( string input , string expectedOutput )
6664 {
6765 var psi = GlobalSetup . CreateRunProcess ( ) ;
68-
6966 using var proc = Process . Start ( psi ) ;
7067
71- var output = new StringBuilder ( ) ;
72-
7368 await proc . StandardInput . WriteLineAsync ( input ) . ConfigureAwait ( false ) ;
69+
7470 await proc . StandardInput . FlushAsync ( ) . ConfigureAwait ( false ) ;
7571 proc . StandardInput . Close ( ) ;
7672
73+ var output = new StringBuilder ( ) ;
7774 proc . ErrorDataReceived += ( _ , args ) =>
7875 {
7976 if ( args . Data is not null )
@@ -85,7 +82,6 @@ public async Task ErrorOutputs(string input, string expectedOutput)
8582 proc . BeginErrorReadLine ( ) ;
8683
8784 var ct = TestContext . Current . Execution . CancellationToken ;
88-
8985 await proc . WaitForExitAsync ( ct ) . ConfigureAwait ( false ) ;
9086
9187 await Assert . That ( output . ToString ( ) ) . Contains ( expectedOutput ) ;
@@ -94,18 +90,56 @@ public async Task ErrorOutputs(string input, string expectedOutput)
9490 [ Test ]
9591 public async Task ConversionSucceeds ( )
9692 {
97- var psi = GlobalSetup . CreateRunProcess ( ) ;
93+ var testFile = Path . Join ( AppContext . BaseDirectory , "Testvideos" , "example_mp4.mp4" ) ;
94+ var input = $ "{ testFile } -f webm";
9895
96+ var psi = GlobalSetup . CreateRunProcess ( ) ;
9997 using var proc = Process . Start ( psi ) ;
10098
99+ await proc . StandardInput . WriteLineAsync ( input ) . ConfigureAwait ( false ) ;
100+
101+ await proc . StandardInput . FlushAsync ( ) . ConfigureAwait ( false ) ;
102+ proc . StandardInput . Close ( ) ;
103+
101104 var output = new StringBuilder ( ) ;
105+ proc . OutputDataReceived += ( _ , args ) =>
106+ {
107+ if ( args . Data is not null )
108+ {
109+ output . AppendLine ( args . Data ) ;
110+ }
111+ } ;
102112
103- var testFile = Path . Join ( AppContext . BaseDirectory , "Testvideos" , "example_webm.webm" ) ;
113+ proc . BeginOutputReadLine ( ) ;
114+
115+ var ct = TestContext . Current . Execution . CancellationToken ;
116+ await proc . WaitForExitAsync ( ct ) . ConfigureAwait ( false ) ;
117+
118+ await Assert . That ( output . ToString ( ) ) . Contains ( "Successfully converted file" ) ;
119+ }
120+
121+
122+ [ Test ]
123+ public async Task ConversionWitDownloadSucceeds ( )
124+ {
125+ var testFile = Environment . GetEnvironmentVariable ( "TESTFILE_URL" ) ;
126+
127+ if ( string . IsNullOrEmpty ( testFile ) )
128+ {
129+ Skip . Test ( "No test file provided" ) ;
130+ }
131+
132+ var input = $ "{ testFile } -f mp4";
133+
134+ var psi = GlobalSetup . CreateRunProcess ( ) ;
135+ using var proc = Process . Start ( psi ) ;
136+
137+ await proc . StandardInput . WriteLineAsync ( input ) . ConfigureAwait ( false ) ;
104138
105- await proc . StandardInput . WriteLineAsync ( testFile ) . ConfigureAwait ( false ) ;
106139 await proc . StandardInput . FlushAsync ( ) . ConfigureAwait ( false ) ;
107140 proc . StandardInput . Close ( ) ;
108141
142+ var output = new StringBuilder ( ) ;
109143 proc . OutputDataReceived += ( _ , args ) =>
110144 {
111145 if ( args . Data is not null )
@@ -117,7 +151,6 @@ public async Task ConversionSucceeds()
117151 proc . BeginOutputReadLine ( ) ;
118152
119153 var ct = TestContext . Current . Execution . CancellationToken ;
120-
121154 await proc . WaitForExitAsync ( ct ) . ConfigureAwait ( false ) ;
122155
123156 await Assert . That ( output . ToString ( ) ) . Contains ( "Successfully converted file" ) ;
0 commit comments