@@ -17,6 +17,30 @@ public void Setup()
1717 Directory . CreateDirectory ( TestOutputDir ) ;
1818 }
1919
20+ [ Test ]
21+ public async Task TestSetOutputFileName ( )
22+ {
23+ var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
24+ var copyOfInputFile = Path . Combine ( TestOutputDir , "simple.pdf" ) ;
25+ File . Copy ( inputFile , copyOfInputFile ) ;
26+ var outputFile = Path . Combine ( TestOutputDir , "simple2.pdf" ) ;
27+
28+ await Program . Main ( [ ApiToken , outputFile , copyOfInputFile , "pdf" , "repair" ] ) ;
29+
30+ Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
31+ }
32+
33+ [ Test ]
34+ public async Task TestGenerateSafeFiles ( )
35+ {
36+ var outputFile = Path . Combine ( TestOutputDir , "output.png" ) ;
37+ var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "22pages.pdf" ) ;
38+
39+ await Program . Main ( [ ApiToken , outputFile , inputFile ] ) ;
40+
41+ Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
42+ }
43+
2044 [ Test ]
2145 public async Task TestConvertPdfToDocx ( )
2246 {
@@ -34,90 +58,90 @@ public async Task TestMergePdfs()
3458 var outputFile = Path . Combine ( TestOutputDir , "simple.pdf" ) ;
3559 var inputFile1 = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
3660 var inputFile2 = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "invoice.pdf" ) ;
37-
61+
3862 await Program . Main ( [ ApiToken , TestOutputDir , inputFile1 , inputFile2 , "pdf" , "merge" ] ) ;
39-
63+
4064 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
4165 }
42-
66+
4367 [ Test ]
4468 public async Task TestMergeMutiplePdfs ( )
4569 {
4670 var outputFile = Path . Combine ( TestOutputDir , "simple.pdf" ) ;
4771 var inputFile1 = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
4872 var inputFile2 = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "invoice.pdf" ) ;
4973 var inputFile3 = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "invoice.pdf" ) ;
50-
74+
5175 await Program . Main ( [ ApiToken , TestOutputDir , inputFile1 , inputFile2 , inputFile3 , "pdf" , "merge" ] ) ;
52-
76+
5377 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
5478 }
55-
79+
5680 [ Test ]
5781 public async Task TestAddWatermarkToPdf ( )
5882 {
5983 var outputFile = Path . Combine ( TestOutputDir , "watermark.pdf" ) ;
6084 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
61-
85+
6286 await Program . Main ( [ ApiToken , TestOutputDir , inputFile , "pdf" , "watermark" , "Text=Confidential" , "FileName=watermark" ] ) ;
63-
64-
87+
88+
6589 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
6690 }
67-
91+
6892 [ Test ]
6993 public async Task TestAddWatermarkOverlayToPdf ( )
7094 {
7195 var outputFile = Path . Combine ( TestOutputDir , "watermarkOverlay.pdf" ) ;
7296 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
7397 var overlayFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
74-
98+
7599 await Program . Main ( [ ApiToken , TestOutputDir , inputFile , "pdf" , "watermark-overlay" , $ "OverlayFile={ overlayFile } ", "FileName=watermarkOverlay" ] ) ;
76-
100+
77101 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
78102 }
79-
103+
80104 [ Test ]
81105 public async Task TestDocxCompare ( )
82106 {
83107 var outputFile = Path . Combine ( TestOutputDir , "demo.docx" ) ;
84108 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "demo.docx" ) ;
85109 var compareFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "demo-changed.docx" ) ;
86-
110+
87111 await Program . Main ( [ ApiToken , TestOutputDir , inputFile , "docx" , "compare" , $ "CompareFile={ compareFile } ", "storeFile=false" ] ) ;
88-
112+
89113 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
90114 }
91-
115+
92116 [ Test ]
93117 public async Task TestProtectPdfWithPassword ( )
94118 {
95119 var outputFile = Path . Combine ( TestOutputDir , "protected.pdf" ) ;
96120 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
97-
121+
98122 await Program . Main ( [ ApiToken , TestOutputDir , inputFile , "pdf" , "protect" , "UserPassword=1234" , "OwnerPassword=abcd" , "FileName=protected" ] ) ;
99-
123+
100124 Assert . IsTrue ( File . Exists ( outputFile ) , "Output file was not created." ) ;
101125 }
102-
126+
103127 [ Test ]
104128 public async Task TestPdfToPngWithResolution ( )
105129 {
106130 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "22pages.pdf" ) ;
107-
131+
108132 await Program . Main ( [ ApiToken , TestOutputDir , inputFile , "pdf" , "png" , "Resolution=300" ] ) ;
109133
110134 var outputFiles = Directory . GetFiles ( TestOutputDir ) ;
111135 Assert . That ( outputFiles , Has . Length . EqualTo ( 22 ) , "Output files were not created." ) ;
112136 }
113-
137+
114138 [ Test ]
115139 public async Task TestPdfToExtractImages ( )
116140 {
117141 var inputFile = Path . Combine ( Directory . GetCurrentDirectory ( ) , "../../../../" , "test_files" , "simple.pdf" ) ;
118-
142+
119143 await Program . Main ( [ ApiToken , TestOutputDir , inputFile , "pdf" , "extract-images" ] ) ;
120-
144+
121145 var outputFiles = Directory . GetFiles ( TestOutputDir ) ;
122146 Assert . That ( outputFiles , Has . Length . EqualTo ( 1 ) , "Output file was not created." ) ;
123147 }
@@ -126,16 +150,16 @@ public async Task TestPdfToExtractImages()
126150 public async Task TestWebToPdf ( )
127151 {
128152 await Program . Main ( [ ApiToken , TestOutputDir , "" , "web" , "pdf" , "url=https://www.google.com" ] ) ;
129-
153+
130154 var outputFiles = Directory . GetFiles ( TestOutputDir ) ;
131155 Assert . That ( outputFiles , Has . Length . EqualTo ( 1 ) , "Output file was not created." ) ;
132156 }
133-
157+
134158 [ Test ]
135159 public async Task TestWebToPdfWithNullasInput ( )
136160 {
137161 await Program . Main ( [ ApiToken , TestOutputDir , null , "web" , "pdf" , "url=https://www.google.com" ] ) ;
138-
162+
139163 var outputFiles = Directory . GetFiles ( TestOutputDir ) ;
140164 Assert . That ( outputFiles , Has . Length . EqualTo ( 1 ) , "Output file was not created." ) ;
141165 }
0 commit comments