@@ -13,11 +13,11 @@ public class CliTest
1313 [ Test ]
1414 public void CliGenerated ( )
1515 {
16- RunCmdCommand ( $ "dotnet { pathToSlnDirectory } /TypeScript.ContractGenerator.Cli/bin/{ configuration } /net7.0 /SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
17- $ "-a { pathToSlnDirectory } /AspNetCoreExample.Api/bin/{ configuration } /net7.0 /AspNetCoreExample.Api.dll " +
18- $ "-o { TestContext . CurrentContext . TestDirectory } /cliOutput " +
19- "--nullabilityMode NullableReference " +
20- "--lintMode TsLint" ) ;
16+ RunDotnetCommand ( $ "{ pathToSlnDirectory } /TypeScript.ContractGenerator.Cli/bin/{ configuration } /{ targetFramework } /SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
17+ $ "-a { pathToSlnDirectory } /AspNetCoreExample.Api/bin/{ configuration } /{ targetFramework } /AspNetCoreExample.Api.dll " +
18+ $ "-o { TestContext . CurrentContext . TestDirectory } /cliOutput " +
19+ "--nullabilityMode NullableReference " +
20+ "--lintMode TsLint" ) ;
2121
2222 var expectedDirectory = $ "{ pathToSlnDirectory } /AspNetCoreExample.Generator/output";
2323 var actualDirectory = $ "{ TestContext . CurrentContext . TestDirectory } /cliOutput";
@@ -27,40 +27,47 @@ public void CliGenerated()
2727 [ Test ]
2828 public void RoslynCliGenerated ( )
2929 {
30- RunCmdCommand ( $ "dotnet { pathToSlnDirectory } /TypeScript.ContractGenerator.Cli/bin/{ configuration } /net7.0 /SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
31- $ "-d { pathToSlnDirectory } /AspNetCoreExample.Api " +
32- $ "-a { typeof ( ControllerBase ) . Assembly . Location } " +
33- $ "-o { TestContext . CurrentContext . TestDirectory } /roslynCliOutput " +
34- "--nullabilityMode NullableReference " +
35- "--lintMode TsLint" ) ;
30+ RunDotnetCommand ( $ "{ pathToSlnDirectory } /TypeScript.ContractGenerator.Cli/bin/{ configuration } /{ targetFramework } /SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
31+ $ "-d { pathToSlnDirectory } /AspNetCoreExample.Api " +
32+ $ "-a { typeof ( ControllerBase ) . Assembly . Location } " +
33+ $ "-o { TestContext . CurrentContext . TestDirectory } /roslynCliOutput " +
34+ "--nullabilityMode NullableReference " +
35+ "--lintMode TsLint" ) ;
3636
3737 var expectedDirectory = $ "{ pathToSlnDirectory } /AspNetCoreExample.Generator/output";
3838 var actualDirectory = $ "{ TestContext . CurrentContext . TestDirectory } /roslynCliOutput";
3939 TestBase . CheckDirectoriesEquivalenceInner ( expectedDirectory , actualDirectory , generatedOnly : true ) ;
4040 }
4141
42- private static void RunCmdCommand ( string command )
42+ private static void RunDotnetCommand ( string command )
4343 {
4444 var process = new Process
4545 {
46- StartInfo =
46+ StartInfo = new ProcessStartInfo ( "dotnet" , command )
4747 {
48- FileName = "cmd.exe" ,
4948 WindowStyle = ProcessWindowStyle . Hidden ,
50- Arguments = "/C " + command ,
51- }
49+ RedirectStandardOutput = true ,
50+ RedirectStandardError = true ,
51+ UseShellExecute = false
52+ } ,
5253 } ;
54+
5355 process . Start ( ) ;
5456 process . WaitForExit ( ) ;
57+
5558 process . ExitCode . Should ( ) . Be ( 0 ) ;
59+ process . StandardOutput . ReadToEnd ( ) . Trim ( ) . Should ( ) . Be ( "Generating TypeScript" ) ;
60+ process . StandardError . ReadToEnd ( ) . Trim ( ) . Should ( ) . BeEmpty ( ) ;
5661 }
5762
5863 private static readonly string pathToSlnDirectory = $ "{ TestContext . CurrentContext . TestDirectory } /../../../../";
5964
65+ private const string targetFramework = "net8.0" ;
66+
6067#if RELEASE
61- const string configuration = "Release" ;
68+ private const string configuration = "Release" ;
6269#elif DEBUG
63- const string configuration = "Debug" ;
70+ private const string configuration = "Debug" ;
6471#endif
6572 }
6673}
0 commit comments