11using CommandLine ;
22using NUnit . Framework ;
33using System . Collections . Generic ;
4+ using System . IO ;
45using TeamTools . TSQL . Linter . CommandLine . Config ;
56
67namespace TeamTools . TSQL . Linter . CommandLineTests
78{
89 [ Category ( "Linter.ConsoleExe" ) ]
9- public class CommandLintOptionsTests
10+ public class CommandLineOptionsTests
1011 {
1112 private Dictionary < string , List < string > > argVariants ;
13+ #if Windows
14+ private const string BasePath = @"c:\" ;
15+ #else
16+ private const string BasePath = @"/home/" ;
17+ #endif
1218
1319 [ SetUp ]
1420 public void Setup ( )
1521 {
1622 argVariants = new Dictionary < string , List < string > >
1723 {
18- { "scan dir" , new List < string > { "--config" , "c: \\ conf.json", "--dir" , "c: \\ src" } } ,
19- { "scan file" , new List < string > { "--config" , "c: \\ conf.json", "--file" , "c: \\ src\\ file.sql" } } ,
20- { "scan diff" , new List < string > { "--config" , "c: \\ conf.json", "--dir" , "c: \\ src\\ proj", "--diff" , "--format" , "json" , "--basepath" , "c: \\ src", "--output" , "c: \\ report.json", "--verbose" } } ,
24+ { "scan dir" , new List < string > { "--config" , BasePath + " conf.json", "--dir" , BasePath + " src" } } ,
25+ { "scan file" , new List < string > { "--config" , BasePath + " conf.json", "--file" , Path . Combine ( BasePath , " src" , " file.sql") } } ,
26+ { "scan diff" , new List < string > { "--config" , BasePath + " conf.json", "--dir" , Path . Combine ( BasePath , " src" , " proj") , "--diff" , "--format" , "json" , "--basepath" , BasePath + " src", "--output" , BasePath + " report.json", "--verbose" } } ,
2127 } ;
2228 }
2329
@@ -42,10 +48,10 @@ public void TestAllArgumentsExtractedCorrectly()
4248 . WithNotParsed ( err => Assert . Fail ( string . Join ( ";" , err ) ) ) ;
4349
4450 Assert . That ( parsedOpts , Is . Not . Null ) ;
45- Assert . That ( parsedOpts . ConfigFile , Is . EqualTo ( "c: \\ conf.json") ) ;
46- Assert . That ( parsedOpts . DirectoryName , Is . EqualTo ( "c: \\ src\\ proj") ) ;
47- Assert . That ( parsedOpts . BasePath , Is . EqualTo ( "c: \\ src") ) ;
48- Assert . That ( parsedOpts . OutputFile , Is . EqualTo ( "c: \\ report.json") ) ;
51+ Assert . That ( parsedOpts . ConfigFile , Is . EqualTo ( BasePath + " conf.json") ) ;
52+ Assert . That ( parsedOpts . DirectoryName , Is . EqualTo ( Path . Combine ( BasePath , " src" , " proj") ) ) ;
53+ Assert . That ( parsedOpts . BasePath , Is . EqualTo ( BasePath + " src") ) ;
54+ Assert . That ( parsedOpts . OutputFile , Is . EqualTo ( BasePath + " report.json") ) ;
4955 Assert . That ( parsedOpts . Format , Is . EqualTo ( OutputFileFormat . JSON ) ) ;
5056 Assert . That ( string . IsNullOrEmpty ( parsedOpts . FileListSource ) , Is . True ) ;
5157 Assert . That ( string . IsNullOrEmpty ( parsedOpts . FileName ) , Is . True ) ;
0 commit comments