Skip to content

Commit 2ac3256

Browse files
Merge pull request #3 from kaferi/master
PDFCLOUD-360, PDFCLOUD-361, PDFCLOUD-362
2 parents 6f86db0 + 1b8d6c7 commit 2ac3256

15 files changed

+502
-128
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ project.lock.json
189189
*.vc.vc.opendb
190190
*.vc.db
191191

192-
# Rider
192+
# IDE
193193
.idea/
194194

195195
# Output folder used by Webpack or other FE stuff
@@ -201,4 +201,6 @@ project.lock.json
201201
*.feature.xlsx.*
202202
*.Specs_*.html
203203

204-
src/Settings/servercreds.json
204+
src/Settings/servercreds.json
205+
206+
.swagger-codegen/

Aspose.Pdf.Cloud.Sdk.sln

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 15
3-
VisualStudioVersion = 15.0.26430.6
3+
VisualStudioVersion = 15.0.27428.2011
44
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspose.Pdf.Cloud.Sdk.Test", "src\Aspose.Pdf.Cloud.Sdk.Test\Aspose.Pdf.Cloud.Sdk.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspose.Pdf.Cloud.Sdk", "src\Aspose.Pdf.Cloud.Sdk\Aspose.Pdf.Cloud.Sdk.csproj", "{2A08C54A-509C-4825-A1F1-CE338F0F8253}"
66
EndProject
7-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspose.Pdf.Cloud.Sdk", "src\Aspose.Pdf.Cloud.Sdk\Aspose.Pdf.Cloud.Sdk.csproj", "{EF4CE7EF-DD3C-4654-8B0A-4BF813184EE4}"
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspose.Pdf.Cloud.Sdk.Test", "src\Aspose.Pdf.Cloud.Sdk.Test\Aspose.Pdf.Cloud.Sdk.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
88
EndProject
99
Global
1010
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1111
Debug|Any CPU = Debug|Any CPU
1212
Release|Any CPU = Release|Any CPU
1313
EndGlobalSection
1414
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15+
{2A08C54A-509C-4825-A1F1-CE338F0F8253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{2A08C54A-509C-4825-A1F1-CE338F0F8253}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{2A08C54A-509C-4825-A1F1-CE338F0F8253}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{2A08C54A-509C-4825-A1F1-CE338F0F8253}.Release|Any CPU.Build.0 = Release|Any CPU
1519
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1620
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
1721
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
1822
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU
19-
{EF4CE7EF-DD3C-4654-8B0A-4BF813184EE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20-
{EF4CE7EF-DD3C-4654-8B0A-4BF813184EE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
21-
{EF4CE7EF-DD3C-4654-8B0A-4BF813184EE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
22-
{EF4CE7EF-DD3C-4654-8B0A-4BF813184EE4}.Release|Any CPU.Build.0 = Release|Any CPU
2323
EndGlobalSection
2424
GlobalSection(SolutionProperties) = preSolution
2525
HideSolutionNode = FALSE
2626
EndGlobalSection
27+
GlobalSection(ExtensibilityGlobals) = postSolution
28+
SolutionGuid = {BA12F496-1994-413B-BEFB-A6A1D3247D6C}
29+
EndGlobalSection
2730
EndGlobal

src/Aspose.Pdf.Cloud.Sdk.Test/AppendTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// </summary>
2424
// --------------------------------------------------------------------------------------------------------------------
2525

26+
using System.IO;
2627
using System.Net;
2728
using Aspose.Pdf.Cloud.Sdk.Model;
2829
using NUnit.Framework;
@@ -50,7 +51,7 @@ public void PostAppendDocumentUsingQueryParamsTest()
5051
UploadFile(AppendFile, AppendFile);
5152

5253
var responce =
53-
PdfApi.PostAppendDocument(Name, appendFile: AppendFile, startPage: StartPage, endPage: EndPage, folder: TempFolder);
54+
PdfApi.PostAppendDocument(Name, appendFile: Path.Combine(TempFolder, AppendFile), startPage: StartPage, endPage: EndPage, folder: TempFolder);
5455
Assert.That(responce.Code, Is.EqualTo(HttpStatusCode.OK));
5556
}
5657

@@ -63,7 +64,7 @@ public void PostAppendDocumentUsingBodyParamsTest()
6364
UploadFile(Name, Name);
6465
UploadFile(AppendFile, AppendFile);
6566

66-
var appendDocument = new AppendDocument(AppendFile, StartPage, EndPage);
67+
var appendDocument = new AppendDocument(Path.Combine(TempFolder, AppendFile), StartPage, EndPage);
6768
var responce =
6869
PdfApi.PostAppendDocument(Name, appendDocument, folder: TempFolder);
6970
Assert.That(responce.Code, Is.EqualTo(HttpStatusCode.OK));

src/Aspose.Pdf.Cloud.Sdk.Test/Aspose.Pdf.Cloud.Sdk.Test.csproj

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ OpenAPI spec version: 1.1
3737
<WarningLevel>4</WarningLevel>
3838
</PropertyGroup>
3939
<ItemGroup>
40-
<Reference Include="Aspose.Storage.Cloud.Sdk, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
41-
<HintPath>..\..\packages\Aspose.Storage-Cloud.18.3.0\lib\net20\Aspose.Storage.Cloud.Sdk.dll</HintPath>
40+
<Reference Include="RestSharp, Version=105.1.0.0, Culture=neutral, processorArchitecture=MSIL">
41+
<HintPath>..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
4242
</Reference>
4343
<Reference Include="System" />
4444
<Reference Include="System.Core" />
@@ -56,12 +56,6 @@ OpenAPI spec version: 1.1
5656
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
5757
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
5858
</Reference>
59-
<Reference Include="RestSharp">
60-
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
61-
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
62-
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
63-
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
64-
</Reference>
6559
<Reference Include="nunit.framework">
6660
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
6761
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
@@ -91,6 +85,7 @@ OpenAPI spec version: 1.1
9185
<Compile Include="PropertiesTests.cs" />
9286
<Compile Include="SignTests.cs" />
9387
<Compile Include="TestBase.cs" />
88+
<Compile Include="UploadDownloadTests.cs" />
9489
</ItemGroup>
9590
<ItemGroup>
9691
<None Include="app.config" />

src/Aspose.Pdf.Cloud.Sdk.Test/DocumentSaveAsTiffTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,21 @@ public void PutDocumentSaveAsTiffUsingQueryParamsTest()
4848
var response = PdfApi.PutDocumentSaveAsTiff(Name,
4949
resultFile: "4pages.tiff",
5050
brightness: 0.6,
51-
compression: "Ccitt4",
52-
colorDepth: "format1bpp",
51+
compression: CompressionType.CCITT4.ToString(),
52+
colorDepth: ColorDepth.Format1bpp.ToString(),
5353
leftMargin: 0,
5454
rightMargin: 0,
5555
topMargin: 0,
5656
bottomMargin: 0,
57-
orientation: "portait",
57+
orientation: ShapeType.Portrait.ToString(),
5858
skipBlankPages: true,
5959
width: 1200,
6060
height: 1600,
6161
xResolution: 200,
6262
yResolution: 200,
6363
pageIndex: 2,
64-
pageCount: 2);
64+
pageCount: 2,
65+
folder: TempFolder);
6566
Assert.That(response.Code, Is.EqualTo(HttpStatusCode.OK));
6667
}
6768

@@ -91,7 +92,7 @@ public void PutDocumentSaveAsTiffUsingBodyParamsTest()
9192
PageIndex: 2,
9293
PageCount: 2);
9394

94-
var response = PdfApi.PutDocumentSaveAsTiff(Name, options);
95+
var response = PdfApi.PutDocumentSaveAsTiff(Name, options, folder: TempFolder);
9596
Assert.That(response.Code, Is.EqualTo(HttpStatusCode.OK));
9697
}
9798
}

src/Aspose.Pdf.Cloud.Sdk.Test/DocumentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ public void PutCreateDocumentFromImagesTest()
138138
const string image2 = "44781.jpg";
139139
UploadFile(image2, image2);
140140

141-
const string name = "pdffromimagesinquery.pdf";
141+
const string name = "pdffromimagesinquery_net.pdf";
142142

143143
var request = new ImagesListRequest(new List<string>
144144
{
145145
Path.Combine(TempFolder, image1),
146146
Path.Combine(TempFolder, image2)
147147
});
148148

149-
var response = PdfApi.PutCreateDocumentFromImages(name, request, false, folder: TempFolder);
149+
var response = PdfApi.PutCreateDocumentFromImages(name, images: request, ocr: false, folder: TempFolder);
150150
Assert.That(response.Code, Is.EqualTo(HttpStatusCode.OK));
151151
}
152152
}

src/Aspose.Pdf.Cloud.Sdk.Test/TestBase.cs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
using System.Threading.Tasks;
2929
using Aspose.Pdf.Cloud.Sdk.Api;
3030
using Aspose.Pdf.Cloud.Sdk.Client;
31-
using Aspose.Storage.Cloud.Sdk.Api;
32-
using Aspose.Storage.Cloud.Sdk.Model.Requests;
3331
using Newtonsoft.Json;
3432
using NUnit.Framework;
3533
using RestSharp.Extensions;
@@ -39,7 +37,7 @@ namespace Aspose.Pdf.Cloud.Sdk.Test
3937
public abstract class TestsBase
4038
{
4139
private const string BaseProductUri = @"http://api-dev.aspose.cloud";
42-
40+
4341
protected const string TestDataFolder = @"..\..\..\..\testData";
4442
private const string ServerCredsFile = @"..\..\..\Settings\servercreds.json";
4543

@@ -52,7 +50,8 @@ public virtual void SetUp()
5250
{
5351
// To run tests with your own credentials please uncomment following line of code
5452
// this.keys = new Keys { AppKey = "your app key", AppSID = "your app sid" };
55-
53+
54+
5655
if (null == keys)
5756
{
5857
keys = JsonConvert.DeserializeObject<Keys>(File.ReadAllText(ServerCredsFile));
@@ -63,27 +62,15 @@ public virtual void SetUp()
6362
throw new FileNotFoundException("servercreds.json doesn't contain AppKey and AppSid");
6463
}
6564

66-
var storageConfiguration = new global::Aspose.Storage.Cloud.Sdk.Configuration()
67-
{
68-
AuthType = global::Aspose.Storage.Cloud.Sdk.Api.AuthType.OAuth2,
69-
AppKey = keys.AppKey,
70-
AppSid = keys.AppSID,
71-
ApiBaseUrl = BaseProductUri
72-
};
73-
74-
StorageApi = new StorageApi(storageConfiguration);
75-
76-
Configuration = new Configuration(keys.AppKey, keys.AppSID, BaseProductUri, authType: AuthType.OAuth2);
65+
Configuration = new Configuration(keys.AppKey, keys.AppSID, BaseProductUri);
7766
PdfApi = new PdfApi(Configuration);
7867
}
7968

8069
[TearDown]
8170
public virtual void TearDown()
8271
{
83-
StorageApi = null;
8472
}
8573

86-
protected StorageApi StorageApi { get; private set; }
8774
protected PdfApi PdfApi { get; set; }
8875
protected Configuration Configuration { get; private set; }
8976

@@ -92,9 +79,7 @@ protected void UploadFile(string sourcePath, string serverFileName)
9279
{
9380
using (var file = File.OpenRead(Path.Combine(TestDataFolder, sourcePath)))
9481
{
95-
PutCreateRequest request = new PutCreateRequest(Path.Combine(TempFolder, serverFileName), file);
96-
97-
var response = StorageApi.PutCreate(request);
82+
var response = PdfApi.PutCreate(Path.Combine(TempFolder, serverFileName), file);
9883
}
9984
}
10085

src/Aspose.Pdf.Cloud.Sdk/Api/AuthType.cs renamed to src/Aspose.Pdf.Cloud.Sdk.Test/UploadDownloadTests.cs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
2-
// <copyright company="Aspose" file="AuthType.cs">
3-
// Copyright (c) 2016 Aspose.Pdf for Cloud
2+
// <copyright company="Aspose" file="MergeTests.cs">
3+
// Copyright (c) 2018 Aspose.Pdf for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,21 +23,47 @@
2323
// </summary>
2424
// --------------------------------------------------------------------------------------------------------------------
2525

26-
namespace Aspose.Pdf.Cloud.Sdk
26+
using System.Collections.Generic;
27+
using System.IO;
28+
using System.Net;
29+
using Aspose.Pdf.Cloud.Sdk.Model;
30+
using NUnit.Framework;
31+
32+
33+
namespace Aspose.Pdf.Cloud.Sdk.Test
2734
{
2835
/// <summary>
29-
/// Supported types of authentification.
36+
/// Class for testing Storage Access Api
3037
/// </summary>
31-
public enum AuthType
38+
[TestFixture]
39+
class UploadDownloadTests : TestsBase
3240
{
3341
/// <summary>
34-
/// OAuth2.0
42+
/// Test Upload file
3543
/// </summary>
36-
OAuth2 = 0,
44+
[Test]
45+
public void PutCreateTest()
46+
{
47+
string name = "4pages.pdf";
48+
49+
using (var file = File.OpenRead(Path.Combine(TestDataFolder, name)))
50+
{
51+
var response = PdfApi.PutCreate(Path.Combine(TempFolder, name), file);
52+
Assert.That(response.Code, Is.EqualTo(HttpStatusCode.OK));
53+
}
54+
}
3755

3856
/// <summary>
39-
/// Authentification with signing of url.
57+
/// Test Upload file
4058
/// </summary>
41-
RequestSignature = 1
59+
[Test]
60+
public void GetDonloadFileTest()
61+
{
62+
string name = "4pages.pdf";
63+
UploadFile(name, name);
64+
65+
var response = PdfApi.GetDownload(Path.Combine(TempFolder, name));
66+
Assert.That(response.Length, Is.GreaterThan(0));
67+
}
4268
}
43-
}
69+
}

src/Aspose.Pdf.Cloud.Sdk.Test/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Aspose.Storage-Cloud" version="18.3.0" targetFramework="net45" />
43
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" developmentDependency="true" />
54
<package id="NUnit" version="2.6.4" targetFramework="net45" />
65
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />

0 commit comments

Comments
 (0)