|
| 1 | +// -------------------------------------------------------------------------------------------------------------------- |
| 2 | +// <copyright company="Aspose" file="PagesTests.cs"> |
| 3 | +// Copyright (c) 2018 Aspose.Pdf for Cloud |
| 4 | +// </copyright> |
| 5 | +// <summary> |
| 6 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +// of this software and associated documentation files (the "Software"), to deal |
| 8 | +// in the Software without restriction, including without limitation the rights |
| 9 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +// copies of the Software, and to permit persons to whom the Software is |
| 11 | +// furnished to do so, subject to the following conditions: |
| 12 | +// |
| 13 | +// The above copyright notice and this permission notice shall be included in all |
| 14 | +// copies or substantial portions of the Software. |
| 15 | +// |
| 16 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | +// SOFTWARE. |
| 23 | +// </summary> |
| 24 | +// -------------------------------------------------------------------------------------------------------------------- |
| 25 | + |
| 26 | +using System.IO; |
| 27 | +using System.Net; |
| 28 | +using Aspose.Pdf.Cloud.Sdk.Model; |
| 29 | +using NUnit.Framework; |
| 30 | + |
| 31 | +namespace Aspose.Pdf.Cloud.Sdk.Test |
| 32 | +{ |
| 33 | + /// <summary> |
| 34 | + /// Class for testing Convert Api |
| 35 | + /// </summary> |
| 36 | + [TestFixture] |
| 37 | + public class ConvertToPdfTests : TestsBase |
| 38 | + { |
| 39 | + /// <summary> |
| 40 | + /// Test GetEpubInStorageToPdf |
| 41 | + /// </summary> |
| 42 | + [Test] |
| 43 | + public void GetEpubInStorageToPdfTest() |
| 44 | + { |
| 45 | + string name = "4pages.epub"; |
| 46 | + UploadFile(name, name); |
| 47 | + |
| 48 | + using (var response = PdfApi.GetEpubInStorageToPdf(Path.Combine(TempFolder, name))) |
| 49 | + { |
| 50 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// Test PutEpubInStorageToPdf |
| 56 | + /// </summary> |
| 57 | + [Test] |
| 58 | + public void PutEpubInStorageToPdfTest() |
| 59 | + { |
| 60 | + string name = "4pages.epub"; |
| 61 | + UploadFile(name, name); |
| 62 | + string resultName = "fromEpub.pdf"; |
| 63 | + |
| 64 | + var response = PdfApi.PutEpubInStorageToPdf(resultName, Path.Combine(TempFolder, name), TempFolder); |
| 65 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 66 | + } |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Test GetWebInStorageToPdf |
| 70 | + /// </summary> |
| 71 | + [Test] |
| 72 | + public void GetWebInStorageToPdfTest() |
| 73 | + { |
| 74 | + string sourceUrl = "http://google.com"; |
| 75 | + |
| 76 | + using (var response = PdfApi.GetWebInStorageToPdf(sourceUrl)) |
| 77 | + { |
| 78 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// Test PutWebInStorageToPdf |
| 84 | + /// </summary> |
| 85 | + [Test] |
| 86 | + public void PutWebInStorageToPdfTest() |
| 87 | + { |
| 88 | + string sourceUrl = "http://google.com"; |
| 89 | + string resultName = "fromWeb.pdf"; |
| 90 | + |
| 91 | + var response = PdfApi.PutWebInStorageToPdf(resultName, sourceUrl, dstFolder: TempFolder); |
| 92 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 93 | + } |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + /// <summary> |
| 98 | + /// Test GetLaTeXInStorageToPdf |
| 99 | + /// </summary> |
| 100 | + [Test] |
| 101 | + public void GetLaTeXInStorageToPdfTest() |
| 102 | + { |
| 103 | + string name = "TexExample.tex"; |
| 104 | + UploadFile(name, name); |
| 105 | + |
| 106 | + using (var response = PdfApi.GetLaTeXInStorageToPdf(Path.Combine(TempFolder, name))) |
| 107 | + { |
| 108 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + /// <summary> |
| 113 | + /// Test PutLaTeXInStorageToPdf |
| 114 | + /// </summary> |
| 115 | + [Test] |
| 116 | + public void PutLaTeXInStorageToPdfTest() |
| 117 | + { |
| 118 | + string name = "TexExample.tex"; |
| 119 | + UploadFile(name, name); |
| 120 | + string resultName = "fromTex.pdf"; |
| 121 | + |
| 122 | + var response = PdfApi.PutLaTeXInStorageToPdf(resultName, Path.Combine(TempFolder, name), TempFolder); |
| 123 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 124 | + } |
| 125 | + |
| 126 | + /// <summary> |
| 127 | + /// Test GetMhtInStorageToPdf |
| 128 | + /// </summary> |
| 129 | + [Test] |
| 130 | + public void GetMhtInStorageToPdfTest() |
| 131 | + { |
| 132 | + string name = "MhtExample.mht"; |
| 133 | + UploadFile(name, name); |
| 134 | + |
| 135 | + using (var response = PdfApi.GetMhtInStorageToPdf(Path.Combine(TempFolder, name))) |
| 136 | + { |
| 137 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + /// <summary> |
| 142 | + /// Test PutMhtInStorageToPdf |
| 143 | + /// </summary> |
| 144 | + [Test] |
| 145 | + public void PutMhtInStorageToPdfTest() |
| 146 | + { |
| 147 | + string name = "MhtExample.mht"; |
| 148 | + UploadFile(name, name); |
| 149 | + string resultName = "fromMht.pdf"; |
| 150 | + |
| 151 | + var response = PdfApi.PutMhtInStorageToPdf(resultName, Path.Combine(TempFolder, name), TempFolder); |
| 152 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 153 | + } |
| 154 | + |
| 155 | + /// <summary> |
| 156 | + /// Test GetHtmlInStorageToPdf |
| 157 | + /// </summary> |
| 158 | + [Test] |
| 159 | + public void GetHtmlInStorageToPdfTest() |
| 160 | + { |
| 161 | + string name = "HtmlWithImage.zip"; |
| 162 | + UploadFile(name, name); |
| 163 | + string htmlFileName = "HtmlWithImage.html"; |
| 164 | + int height = 650; |
| 165 | + int width = 250; |
| 166 | + using (var response = PdfApi.GetHtmlInStorageToPdf(Path.Combine(TempFolder, name), htmlFileName, height, width)) |
| 167 | + { |
| 168 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + /// <summary> |
| 173 | + /// Test PutHtmlInStorageToPdf |
| 174 | + /// </summary> |
| 175 | + [Test] |
| 176 | + public void PutHtmlInStorageToPdfTest() |
| 177 | + { |
| 178 | + string name = "HtmlWithImage.zip"; |
| 179 | + UploadFile(name, name); |
| 180 | + string htmlFileName = "HtmlWithImage.html"; |
| 181 | + int height = 650; |
| 182 | + int width = 250; |
| 183 | + string resultName = "fromHtml.pdf"; |
| 184 | + |
| 185 | + var response = PdfApi.PutHtmlInStorageToPdf(resultName, Path.Combine(TempFolder, name), htmlFileName, height, width, dstFolder: TempFolder); |
| 186 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 187 | + } |
| 188 | + |
| 189 | + |
| 190 | + /// <summary> |
| 191 | + /// Test GetXslFoInStorageToPdf |
| 192 | + /// </summary> |
| 193 | + [Test] |
| 194 | + public void GetXslFoInStorageToPdfTest() |
| 195 | + { |
| 196 | + string name = "XslfoExample.xslfo"; |
| 197 | + UploadFile(name, name); |
| 198 | + |
| 199 | + using (var response = PdfApi.GetXslFoInStorageToPdf(Path.Combine(TempFolder, name))) |
| 200 | + { |
| 201 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 202 | + } |
| 203 | + } |
| 204 | + |
| 205 | + /// <summary> |
| 206 | + /// Test PutXslFoInStorageToPdf |
| 207 | + /// </summary> |
| 208 | + [Test] |
| 209 | + public void PutXslFoInStorageToPdfTest() |
| 210 | + { |
| 211 | + string name = "XslfoExample.xslfo"; |
| 212 | + UploadFile(name, name); |
| 213 | + string resultName = "fromXlsFo.pdf"; |
| 214 | + |
| 215 | + var response = PdfApi.PutXslFoInStorageToPdf(resultName, Path.Combine(TempFolder, name), TempFolder); |
| 216 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 217 | + } |
| 218 | + |
| 219 | + |
| 220 | + /// <summary> |
| 221 | + /// Test GetXpsInStorageToPdf |
| 222 | + /// </summary> |
| 223 | + [Test] |
| 224 | + public void GetXpsInStorageToPdfTest() |
| 225 | + { |
| 226 | + string name = "Simple.xps"; |
| 227 | + UploadFile(name, name); |
| 228 | + |
| 229 | + using (var response = PdfApi.GetXpsInStorageToPdf(Path.Combine(TempFolder, name))) |
| 230 | + { |
| 231 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 232 | + } |
| 233 | + } |
| 234 | + |
| 235 | + /// <summary> |
| 236 | + /// Test PutXpsInStorageToPdf |
| 237 | + /// </summary> |
| 238 | + [Test] |
| 239 | + public void PutXpsInStorageToPdfTest() |
| 240 | + { |
| 241 | + string name = "Simple.xps"; |
| 242 | + UploadFile(name, name); |
| 243 | + string resultName = "fromXps.pdf"; |
| 244 | + |
| 245 | + var response = PdfApi.PutXpsInStorageToPdf(resultName, Path.Combine(TempFolder, name), TempFolder); |
| 246 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 247 | + } |
| 248 | + |
| 249 | + /// <summary> |
| 250 | + /// Test GetSvgInStorageToPdf |
| 251 | + /// </summary> |
| 252 | + [Test] |
| 253 | + public void GetSvgInStorageToPdfTest() |
| 254 | + { |
| 255 | + string name = "Simple.svg"; |
| 256 | + UploadFile(name, name); |
| 257 | + |
| 258 | + using (var response = PdfApi.GetSvgInStorageToPdf(Path.Combine(TempFolder, name))) |
| 259 | + { |
| 260 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 261 | + } |
| 262 | + } |
| 263 | + |
| 264 | + /// <summary> |
| 265 | + /// Test PutSvgInStorageToPdf |
| 266 | + /// </summary> |
| 267 | + [Test] |
| 268 | + public void PutSvgInStorageToPdfTest() |
| 269 | + { |
| 270 | + string name = "Simple.svg"; |
| 271 | + UploadFile(name, name); |
| 272 | + string resultName = "fromSvg.pdf"; |
| 273 | + |
| 274 | + var response = PdfApi.PutSvgInStorageToPdf(resultName, Path.Combine(TempFolder, name), dstFolder: TempFolder); |
| 275 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 276 | + } |
| 277 | + |
| 278 | + /// <summary> |
| 279 | + /// Test GetPclInStorageToPdf |
| 280 | + /// </summary> |
| 281 | + [Test] |
| 282 | + public void GetPclInStorageToPdfTest() |
| 283 | + { |
| 284 | + string name = "template.pcl"; |
| 285 | + UploadFile(name, name); |
| 286 | + |
| 287 | + using (var response = PdfApi.GetPclInStorageToPdf(Path.Combine(TempFolder, name))) |
| 288 | + { |
| 289 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 290 | + } |
| 291 | + } |
| 292 | + |
| 293 | + /// <summary> |
| 294 | + /// Test PutPclInStorageToPdf |
| 295 | + /// </summary> |
| 296 | + [Test] |
| 297 | + public void PutPclInStorageToPdfTest() |
| 298 | + { |
| 299 | + string name = "template.pcl"; |
| 300 | + UploadFile(name, name); |
| 301 | + string resultName = "fromPcl.pdf"; |
| 302 | + |
| 303 | + var response = PdfApi.PutPclInStorageToPdf(resultName, Path.Combine(TempFolder, name), dstFolder: TempFolder); |
| 304 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 305 | + } |
| 306 | + |
| 307 | + |
| 308 | + /// <summary> |
| 309 | + /// Test GetXmlInStorageToPdf |
| 310 | + /// </summary> |
| 311 | + [Test] |
| 312 | + public void GetXmlInStorageToPdfTest() |
| 313 | + { |
| 314 | + string name = "template.xml"; |
| 315 | + UploadFile(name, name); |
| 316 | + |
| 317 | + using (var response = PdfApi.GetXmlInStorageToPdf(Path.Combine(TempFolder, name))) |
| 318 | + { |
| 319 | + Assert.That(response.Length, Is.GreaterThan(0)); |
| 320 | + } |
| 321 | + } |
| 322 | + |
| 323 | + /// <summary> |
| 324 | + /// Test PutXmlInStorageToPdf |
| 325 | + /// </summary> |
| 326 | + [Test] |
| 327 | + public void PutXmlInStorageToPdfTest() |
| 328 | + { |
| 329 | + string name = "template.xml"; |
| 330 | + UploadFile(name, name); |
| 331 | + string resultName = "fromXml.pdf"; |
| 332 | + |
| 333 | + var response = PdfApi.PutXmlInStorageToPdf(resultName, Path.Combine(TempFolder, name), dstFolder: TempFolder); |
| 334 | + Assert.That(response.Code, Is.EqualTo(HttpStatusCode.Created)); |
| 335 | + } |
| 336 | + } |
| 337 | +} |
0 commit comments