@@ -20,86 +20,50 @@ public void Setup()
2020 }
2121
2222 [ Test ]
23- [ TestCase ( true ) ]
24- [ TestCase ( false ) ]
25- public void TestConvertPdfToDocx ( bool cli )
23+ public void TestConvertPdfToDocx ( )
2624 {
2725 var outputFile = Path . Combine ( TestOutputDir , "simple.docx" ) ;
2826 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
2927
30- var process = Run ( $ "{ ApiToken } { outputFile } { inputFile } ", cli , inputFile ) ;
28+ var process = RunCli ( $ "{ ApiToken } { outputFile } { inputFile } ") ;
3129
32- if ( cli )
33- Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
34-
30+ Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
3531 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
3632 }
3733
3834 [ Test ]
39- [ TestCase ( true ) ]
40- [ TestCase ( false ) ]
41- public void TestMergePdfs ( bool cli )
35+ public void TestMergePdfs ( )
4236 {
4337 var outputFile = Path . Combine ( TestOutputDir , "simple.pdf" ) ;
4438 var inputFile1 = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
4539 var inputFile2 = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "invoice.pdf" ) ;
46- var process = Run ( $ "{ ApiToken } { outputFile } { inputFile1 } { inputFile2 } pdf merge" , cli , $ " { inputFile1 } { Environment . NewLine } { inputFile2 } { Environment . NewLine } ") ;
40+ var process = RunCli ( $ "{ ApiToken } { outputFile } { inputFile1 } { inputFile2 } pdf merge") ;
4741
48- if ( cli )
49- Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
50-
42+ Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
5143 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
5244 }
5345
5446 [ Test ]
55- [ TestCase ( true ) ]
56- [ TestCase ( false ) ]
57- public void TestAddWatermarkToPdf ( bool cli )
47+ public void TestAddWatermarkToPdf ( )
5848 {
5949 var outputFile = Path . Combine ( TestOutputDir , "watermark.pdf" ) ;
6050 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
61- var process = Run ( $ "{ ApiToken } { outputFile } { inputFile } pdf watermark Text=Confidential FileName=watermark", cli , inputFile ) ;
51+ var process = RunCli ( $ "{ ApiToken } { outputFile } { inputFile } pdf watermark Text=Confidential FileName=watermark") ;
6252
63- if ( cli )
64- Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
65-
53+ Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
6654 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
6755 }
6856
6957 [ Test ]
70- [ TestCase ( true ) ]
71- [ TestCase ( false ) ]
72- public void TestProtectPdfWithPassword ( bool cli )
58+ public void TestProtectPdfWithPassword ( )
7359 {
7460 var outputFile = Path . Combine ( TestOutputDir , "protected.pdf" ) ;
7561 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
76- var process = Run ( $ "{ ApiToken } { outputFile } { inputFile } pdf protect UserPassword=1234 OwnerPassword=abcd FileName=protected", cli , inputFile ) ;
77-
78- if ( cli )
79- Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
62+ var process = RunCli ( $ "{ ApiToken } { outputFile } { inputFile } pdf protect UserPassword=1234 OwnerPassword=abcd FileName=protected") ;
8063
64+ Assert . AreEqual ( 0 , process . ExitCode , "CLI did not exit cleanly." ) ;
8165 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
8266 }
83-
84- private Process ? Run ( string arguments , bool cli = true , string inputFiles = "" )
85- {
86- if ( cli )
87- return RunCli ( arguments ) ;
88-
89- var originalIn = Console . In ;
90- try
91- {
92- Console . SetIn ( new StringReader ( inputFiles ) ) ;
93- Program . Main ( arguments . Split ( ) ) . GetAwaiter ( ) . GetResult ( ) ;
94- }
95- finally
96- {
97- // Restore the original input
98- Console . SetIn ( originalIn ) ;
99- }
100-
101- return null ;
102- }
10367
10468 private Process RunCli ( string arguments )
10569 {
0 commit comments