1
- using Xunit ;
2
- using Xcaciv . Command ;
3
- using System ;
4
- using System . Collections . Generic ;
5
- using System . Linq ;
6
- using System . Text ;
7
- using System . Threading . Tasks ;
8
- using Xunit . Abstractions ;
9
- using System . IO . Abstractions ;
10
- using Xcaciv . Command . FileLoader ;
11
-
12
- namespace Xcaciv . CommandTests
13
- {
14
- public class CommandControllerTests
15
- {
16
- private ITestOutputHelper _testOutput ;
17
- private string commandPackageDir = @"..\..\..\..\zTestCommandPackage\bin\{1}\" ;
18
- public CommandControllerTests ( ITestOutputHelper output )
19
- {
20
- _testOutput = output ;
21
- #if DEBUG
22
- _testOutput . WriteLine ( "Tests in Debug mode" ) ;
23
- commandPackageDir = commandPackageDir . Replace ( "{1}" , "Debug" ) ;
24
- #else
25
- this . _testOutput . WriteLine ( "Tests in Release mode??" ) ;
26
- this . commandPackageDir = commandPackageDir . Replace ( "{1}" , "Release" ) ;
27
- #endif
28
- }
29
- [ Fact ( ) ]
30
- public async Task RunCommandsTestAsync ( )
31
- {
32
- var commands = new CommandController ( new Crawler ( ) , @"..\..\..\..\..\" ) ;
33
- commands . AddPackageDirectory ( commandPackageDir ) ;
34
-
35
- commands . LoadCommands ( string . Empty ) ;
36
- var textio = new TestImpementations . TestTextIo ( ) ;
37
- // simulate user input
38
- await commands . Run ( "echo what is up" , textio ) ;
39
-
40
- // verify the output of the first run
41
- // by looking at the output of the second output line
42
- Assert . Equal ( "> what" , textio . Children . First ( ) . Output [ 1 ] ) ;
43
- }
44
- [ Fact ( ) ]
45
- public async Task PipeCommandsTestAsync ( )
46
- {
47
- var commands = new CommandController ( new Crawler ( ) , @"..\..\..\..\..\" ) ;
48
- commands . AddPackageDirectory ( commandPackageDir ) ;
49
-
50
- commands . LoadCommands ( string . Empty ) ;
51
- var textio = new TestImpementations . TestTextIo ( ) ;
52
- // simulate user input
53
- await commands . Run ( "echo what is up | echo2 | echoe " , textio ) ;
54
-
55
- // verify the output of the first run
56
- // by looking at the output of the second output line
57
- Assert . Equal ( "> :d2hhdC13aGF0:-:d2hhdC13aGF0:-> :aXMtaXM=:-:aXMtaXM=:-> :dXAtdXA=:-:dXAtdXA=:" , textio . ToString ( ) ) ;
58
- }
59
- }
1
+ using Xunit ;
2
+ using Xcaciv . Command ;
3
+ using System ;
4
+ using System . Collections . Generic ;
5
+ using System . Linq ;
6
+ using System . Text ;
7
+ using System . Threading . Tasks ;
8
+ using Xunit . Abstractions ;
9
+ using System . IO . Abstractions ;
10
+ using Xcaciv . Command . FileLoader ;
11
+
12
+ namespace Xcaciv . Command . Tests
13
+ {
14
+ public class CommandControllerTests
15
+ {
16
+ private ITestOutputHelper _testOutput ;
17
+ private string commandPackageDir = @"..\..\..\..\zTestCommandPackage\bin\{1}\" ;
18
+ public CommandControllerTests ( ITestOutputHelper output )
19
+ {
20
+ _testOutput = output ;
21
+ #if DEBUG
22
+ _testOutput . WriteLine ( "Tests in Debug mode" ) ;
23
+ commandPackageDir = commandPackageDir . Replace ( "{1}" , "Debug" ) ;
24
+ #else
25
+ this . _testOutput . WriteLine ( "Tests in Release mode??" ) ;
26
+ this . commandPackageDir = commandPackageDir . Replace ( "{1}" , "Release" ) ;
27
+ #endif
28
+ }
29
+ [ Fact ( ) ]
30
+ public async Task RunCommandsTestAsync ( )
31
+ {
32
+ var commands = new CommandController ( new Crawler ( ) , @"..\..\..\..\..\" ) ;
33
+ commands . AddPackageDirectory ( commandPackageDir ) ;
34
+
35
+ commands . LoadCommands ( string . Empty ) ;
36
+ var textio = new TestImpementations . TestTextIo ( ) ;
37
+ // simulate user input
38
+ await commands . Run ( "echo what is up" , textio ) ;
39
+
40
+ // verify the output of the first run
41
+ // by looking at the output of the second output line
42
+ Assert . Equal ( "> what" , textio . Children . First ( ) . Output [ 1 ] ) ;
43
+ }
44
+ [ Fact ( ) ]
45
+ public async Task PipeCommandsTestAsync ( )
46
+ {
47
+ var commands = new CommandController ( new Crawler ( ) , @"..\..\..\..\..\" ) ;
48
+ commands . AddPackageDirectory ( commandPackageDir ) ;
49
+
50
+ commands . LoadCommands ( string . Empty ) ;
51
+ var textio = new TestImpementations . TestTextIo ( ) ;
52
+ // simulate user input
53
+ await commands . Run ( "echo what is up | echo2 | echoe " , textio ) ;
54
+
55
+ // verify the output of the first run
56
+ // by looking at the output of the second output line
57
+ Assert . Equal ( "> :d2hhdC13aGF0:-:d2hhdC13aGF0:-> :aXMtaXM=:-:aXMtaXM=:-> :dXAtdXA=:-:dXAtdXA=:" , textio . ToString ( ) ) ;
58
+ }
59
+ }
60
60
}
0 commit comments