@@ -10,15 +10,15 @@ namespace SimpleExecTests;
1010public static class RunningCommands
1111{
1212 private static readonly string command = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? "hello-world.cmd" : "ls" ;
13- private static readonly CancellationToken ct = TestContext . Current . CancellationToken ;
13+ private static CancellationToken Ct => TestContext . Current . CancellationToken ;
1414
1515 public static bool OsPlatformIsWindows => RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
1616
1717 [ Fact ]
1818 public static void RunningASucceedingCommand ( )
1919 {
2020 // act
21- var exception = Record . Exception ( ( ) => Command . Run ( command , cancellationToken : ct ) ) ;
21+ var exception = Record . Exception ( ( ) => Command . Run ( command , cancellationToken : Ct ) ) ;
2222
2323 // assert
2424 Assert . Null ( exception ) ;
@@ -28,7 +28,7 @@ public static void RunningASucceedingCommand()
2828 public static void RunningASucceedingCommandWithArgs ( )
2929 {
3030 // act
31- var exception = Record . Exception ( ( ) => Command . Run ( "dotnet" , $ "exec { Tester . Path } hello world", cancellationToken : ct ) ) ;
31+ var exception = Record . Exception ( ( ) => Command . Run ( "dotnet" , $ "exec { Tester . Path } hello world", cancellationToken : Ct ) ) ;
3232
3333 // assert
3434 Assert . Null ( exception ) ;
@@ -38,7 +38,7 @@ public static void RunningASucceedingCommandWithArgs()
3838 public static async Task RunningASucceedingCommandAsync ( )
3939 {
4040 // act
41- var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( command , cancellationToken : ct ) ) ;
41+ var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( command , cancellationToken : Ct ) ) ;
4242
4343 // assert
4444 Assert . Null ( exception ) ;
@@ -48,7 +48,7 @@ public static async Task RunningASucceedingCommandAsync()
4848 public static void RunningAFailingCommand ( )
4949 {
5050 // act
51- var exception = Record . Exception ( ( ) => Command . Run ( "dotnet" , $ "exec { Tester . Path } 1 hello world", cancellationToken : ct ) ) ;
51+ var exception = Record . Exception ( ( ) => Command . Run ( "dotnet" , $ "exec { Tester . Path } 1 hello world", cancellationToken : Ct ) ) ;
5252
5353 // assert
5454 Assert . Equal ( 1 , Assert . IsType < ExitCodeException > ( exception ) . ExitCode ) ;
@@ -58,7 +58,7 @@ public static void RunningAFailingCommand()
5858 public static async Task RunningAFailingCommandAsync ( )
5959 {
6060 // act
61- var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( "dotnet" , $ "exec { Tester . Path } 1 hello world", cancellationToken : ct ) ) ;
61+ var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( "dotnet" , $ "exec { Tester . Path } 1 hello world", cancellationToken : Ct ) ) ;
6262
6363 // assert
6464 Assert . Equal ( 1 , Assert . IsType < ExitCodeException > ( exception ) . ExitCode ) ;
@@ -68,7 +68,7 @@ public static async Task RunningAFailingCommandAsync()
6868 public static void RunningACommandInANonExistentWorkDirectory ( )
6969 {
7070 // act
71- var exception = Record . Exception ( ( ) => Command . Run ( "dotnet" , $ "exec { Tester . Path } ", "non-existent-working-directory" , cancellationToken : ct ) ) ;
71+ var exception = Record . Exception ( ( ) => Command . Run ( "dotnet" , $ "exec { Tester . Path } ", "non-existent-working-directory" , cancellationToken : Ct ) ) ;
7272
7373 // assert
7474 _ = Assert . IsType < Win32Exception > ( exception ) ;
@@ -78,7 +78,7 @@ public static void RunningACommandInANonExistentWorkDirectory()
7878 public static async Task RunningACommandAsyncInANonExistentWorkDirectory ( )
7979 {
8080 // act
81- var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( "dotnet" , $ "exec { Tester . Path } ", "non-existent-working-directory" , cancellationToken : ct ) ) ;
81+ var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( "dotnet" , $ "exec { Tester . Path } ", "non-existent-working-directory" , cancellationToken : Ct ) ) ;
8282
8383 // assert
8484 _ = Assert . IsType < Win32Exception > ( exception ) ;
@@ -88,7 +88,7 @@ public static async Task RunningACommandAsyncInANonExistentWorkDirectory()
8888 public static void RunningANonExistentCommand ( )
8989 {
9090 // act
91- var exception = Record . Exception ( ( ) => Command . Run ( "simple-exec-tests-non-existent-command" , cancellationToken : ct ) ) ;
91+ var exception = Record . Exception ( ( ) => Command . Run ( "simple-exec-tests-non-existent-command" , cancellationToken : Ct ) ) ;
9292
9393 // assert
9494 _ = Assert . IsType < Win32Exception > ( exception ) ;
@@ -98,7 +98,7 @@ public static void RunningANonExistentCommand()
9898 public static async Task RunningANonExistentCommandAsync ( )
9999 {
100100 // act
101- var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( "simple-exec-tests-non-existent-command" , cancellationToken : ct ) ) ;
101+ var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( "simple-exec-tests-non-existent-command" , cancellationToken : Ct ) ) ;
102102
103103 // assert
104104 _ = Assert . IsType < Win32Exception > ( exception ) ;
@@ -110,7 +110,7 @@ public static async Task RunningANonExistentCommandAsync()
110110 public static void RunningNoCommand ( string name )
111111 {
112112 // act
113- var exception = Record . Exception ( ( ) => Command . Run ( name , cancellationToken : ct ) ) ;
113+ var exception = Record . Exception ( ( ) => Command . Run ( name , cancellationToken : Ct ) ) ;
114114
115115 // assert
116116 Assert . Equal ( nameof ( name ) , Assert . IsType < ArgumentException > ( exception ) . ParamName ) ;
@@ -122,7 +122,7 @@ public static void RunningNoCommand(string name)
122122 public static async Task RunningNoCommandAsync ( string name )
123123 {
124124 // act
125- var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( name , cancellationToken : ct ) ) ;
125+ var exception = await Record . ExceptionAsync ( ( ) => Command . RunAsync ( name , cancellationToken : Ct ) ) ;
126126
127127 // assert
128128 Assert . Equal ( nameof ( name ) , Assert . IsType < ArgumentException > ( exception ) . ParamName ) ;
@@ -147,15 +147,15 @@ public static async Task RunningCommandsInPathOnWindows()
147147
148148 var name = Path . GetFileNameWithoutExtension ( Path . GetRandomFileName ( ) ) ;
149149 var fullName = Path . Combine ( directory , Path . ChangeExtension ( name , "cmd" ) ) ;
150- await File . WriteAllTextAsync ( fullName , "echo foo" , cancellationToken : ct ) ;
150+ await File . WriteAllTextAsync ( fullName , "echo foo" , cancellationToken : Ct ) ;
151151
152152 Environment . SetEnvironmentVariable (
153153 "PATH" ,
154154 $ "{ Environment . GetEnvironmentVariable ( "PATH" ) } { Path . PathSeparator } { directory } ",
155155 EnvironmentVariableTarget . Process ) ;
156156
157157 // act
158- var exception = Record . Exception ( ( ) => Command . Run ( name , cancellationToken : ct ) ) ;
158+ var exception = Record . Exception ( ( ) => Command . Run ( name , cancellationToken : Ct ) ) ;
159159
160160 // assert
161161 Assert . Null ( exception ) ;
@@ -183,10 +183,10 @@ public static async Task RunningCommandsInPathOnWindowsWithSpecificPathExt(
183183
184184 var name = Path . GetFileNameWithoutExtension ( Path . GetRandomFileName ( ) ) ;
185185 var batName = Path . Combine ( directory , Path . ChangeExtension ( name , "bat" ) ) ;
186- await File . WriteAllTextAsync ( batName , "@echo hello from bat" , cancellationToken : ct ) ;
186+ await File . WriteAllTextAsync ( batName , "@echo hello from bat" , cancellationToken : Ct ) ;
187187
188188 var cmdName = Path . Combine ( directory , Path . ChangeExtension ( name , "cmd" ) ) ;
189- await File . WriteAllTextAsync ( cmdName , "@echo hello from cmd" , cancellationToken : ct ) ;
189+ await File . WriteAllTextAsync ( cmdName , "@echo hello from cmd" , cancellationToken : Ct ) ;
190190
191191 Environment . SetEnvironmentVariable (
192192 "PATH" ,
@@ -199,7 +199,7 @@ public static async Task RunningCommandsInPathOnWindowsWithSpecificPathExt(
199199 EnvironmentVariableTarget . Process ) ;
200200
201201 // act
202- var actual = ( await Command . ReadAsync ( name , cancellationToken : ct ) ) . StandardOutput . Trim ( ) ;
202+ var actual = ( await Command . ReadAsync ( name , cancellationToken : Ct ) ) . StandardOutput . Trim ( ) ;
203203
204204 // assert
205205 Assert . Equal ( expected , actual ) ;
0 commit comments