Skip to content

Commit 97dfaa6

Browse files
committed
Updated sources
1 parent 4a14c53 commit 97dfaa6

225 files changed

Lines changed: 15865 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/.gitignore

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
2+
Temp/
3+
obj/
4+
classes/
5+
generated/
6+
*.suo
7+
bin/
8+
*_out_*
9+
* Out*
10+
* out*
11+
*.ldb
12+
Thumbs.db
13+
_ReSharper*/
14+
out/
15+
*.lic
16+
*.user
17+
Out/
18+
Out*/
19+
Data/*Out*
20+
TestResults/
21+
*.ide
22+
*.vsmdi
23+
test-results/
24+
node_modules/
25+
*.userprefs
26+
packages/
27+
*.gitattributes
28+
*.pyc
29+
# Built application files
30+
*.apk
31+
*.ap_
32+
33+
# Files for the ART/Dalvik VM
34+
*.dex
35+
36+
# Java class files
37+
*.class
38+
39+
# Generated files
40+
bin/
41+
gen/
42+
out/
43+
44+
# Gradle files
45+
.gradle/
46+
build/
47+
48+
# Local configuration file (sdk path, etc)
49+
local.properties
50+
51+
# Proguard folder generated by Eclipse
52+
proguard/
53+
54+
# Log Files
55+
*.log
56+
57+
# Android Studio Navigation editor temp files
58+
.navigation/
59+
60+
# Android Studio captures folder
61+
captures/
62+
63+
# Intellij
64+
*.iml
65+
.idea/workspace.xml
66+
.idea/tasks.xml
67+
.idea/gradle.xml
68+
.idea/dictionaries
69+
.idea/libraries
70+
71+
# Keystore files
72+
*.jks
73+
74+
# External native build folder generated in Android Studio 2.2 and later
75+
.externalNativeBuild
76+
77+
# Google Services (e.g. APIs or Firebase)
78+
google-services.json
79+
80+
# Freeline
81+
freeline.py
82+
freeline/
83+
freeline_project_description.json
84+
85+
# Compiled class file
86+
*.class
87+
88+
# Log file
89+
*.log
90+
91+
# BlueJ files
92+
*.ctxt
93+
94+
# Mobile Tools for Java (J2ME)
95+
.mtj.tmp/
96+
97+
# Package Files #
98+
*.war
99+
*.ear
100+
*.zip
101+
*.tar.gz
102+
*.rar
103+
104+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
105+
hs_err_pid*
106+
107+
.DS_Store
108+
*.xcuserstate*StyleCop.Cache
109+
*StyleCop.Cache
110+
.vs/*
111+
112+
.sign-keys
113+
*.nuspec
114+
*.Nuget.csproj
115+
*.nupkg
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose Pty Ltd">
3+
// Copyright (c) 2003-2019 Aspose Pty Ltd
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 GroupDocs.Conversion.Cloud.Sdk.Api;
27+
using GroupDocs.Conversion.Cloud.Sdk.Client;
28+
using GroupDocs.Conversion.Cloud.Sdk.Model.Requests;
29+
30+
namespace GroupDocs.Conversion.Cloud.Sdk.Test.Api
31+
{
32+
using NUnit.Framework;
33+
34+
public class AuthApiTests
35+
{
36+
/// <summary>
37+
/// Test Auth Error
38+
/// </summary>
39+
[Test]
40+
public void AuthErrorWhenAppSidNotFoundTest()
41+
{
42+
var appSid = "test";
43+
var appKey = "test";
44+
45+
var conversionConfig = new Configuration(appSid, appKey)
46+
{
47+
ApiBaseUrl = Config.ApiBaseUrl
48+
};
49+
50+
var infoApi = new InfoApi(conversionConfig);
51+
52+
var ex = Assert.Throws<ApiException>(() => { infoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest()); });
53+
54+
Assert.AreEqual("invalid_client", ex.Message);
55+
}
56+
57+
/// <summary>
58+
/// Test Auth Error
59+
/// </summary>
60+
[Test]
61+
public void AuthErrorWhenAppKeyNotFoundTest()
62+
{
63+
var appSid = Config.AppSid;
64+
var appKey = "test";
65+
66+
var conversionConfig = new Configuration(appSid, appKey)
67+
{
68+
ApiBaseUrl = Config.ApiBaseUrl
69+
};
70+
71+
var infoApi = new InfoApi(conversionConfig);
72+
73+
var ex = Assert.Throws<ApiException>(() =>
74+
{
75+
infoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest());
76+
});
77+
78+
Assert.AreEqual("invalid_client", ex.Message);
79+
}
80+
}
81+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose Pty Ltd">
3+
// Copyright (c) 2003-2019 Aspose Pty Ltd
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;
27+
using System.IO;
28+
using System.Reflection;
29+
using System.Text;
30+
using GroupDocs.Conversion.Cloud.Sdk.Api;
31+
using GroupDocs.Conversion.Cloud.Sdk.Model.Requests;
32+
using Configuration = GroupDocs.Conversion.Cloud.Sdk.Client.Configuration;
33+
34+
namespace GroupDocs.Conversion.Cloud.Sdk.Test.Api
35+
{
36+
using Newtonsoft.Json;
37+
using NUnit.Framework;
38+
using Internal;
39+
40+
public class BaseApiTest
41+
{
42+
private readonly string _appSid = Config.AppSid;
43+
private readonly string _appKey = Config.AppKey;
44+
private readonly string _apiBaseUrl = Config.ApiBaseUrl;
45+
46+
protected ConvertApi ConvertApi;
47+
protected InfoApi InfoApi;
48+
protected FileApi FileApi;
49+
protected FolderApi FolderApi;
50+
protected StorageApi StorageApi;
51+
52+
[OneTimeSetUp]
53+
public void BeforeAllTests()
54+
{
55+
var config = new Configuration(_appSid, _appKey)
56+
{
57+
ApiBaseUrl = _apiBaseUrl
58+
};
59+
60+
ConvertApi = new ConvertApi(config);
61+
InfoApi = new InfoApi(config);
62+
FileApi = new FileApi(config);
63+
FolderApi = new FolderApi(config);
64+
StorageApi = new StorageApi(config);
65+
66+
UploadTestFiles();
67+
}
68+
69+
[TearDown]
70+
public void AfterEachTest()
71+
{
72+
Cleanup();
73+
}
74+
75+
private void UploadTestFiles()
76+
{
77+
foreach (var testFile in TestFiles.TestFilesList)
78+
{
79+
var existRequest = new ObjectExistsRequest(testFile.FullName);
80+
var existResponse = StorageApi.ObjectExists(existRequest);
81+
if(existResponse.Exists == true) continue;
82+
var request = new UploadFileRequest(testFile.FullName, GetTestFileStream(testFile));
83+
FileApi.UploadFile(request);
84+
}
85+
}
86+
87+
private void Cleanup()
88+
{
89+
DeleteFolderFromStorage("conversion");
90+
}
91+
92+
private void DeleteFolderFromStorage(string folderName)
93+
{
94+
var request = new DeleteFolderRequest(folderName, null, true);
95+
FolderApi.DeleteFolder(request);
96+
}
97+
98+
private byte[] GetTestFileBytes(TestFile file)
99+
{
100+
var filePath = Path.Combine(GetTestDataPath(), file.Folder, file.FileName);
101+
if (!File.Exists(filePath))
102+
{
103+
throw new FileNotFoundException("File not found: " + filePath);
104+
}
105+
106+
return File.ReadAllBytes(filePath);
107+
}
108+
109+
protected Stream GetTestFileStream(TestFile file)
110+
{
111+
var bytes = GetTestFileBytes(file);
112+
113+
return new MemoryStream(bytes);
114+
}
115+
116+
// ReSharper disable once UnusedMember.Global
117+
protected Stream SerializeObject(object obj)
118+
{
119+
var options = new JsonSerializerSettings
120+
{
121+
NullValueHandling = NullValueHandling.Ignore
122+
};
123+
var json = JsonConvert.SerializeObject(obj, options);
124+
125+
var bytes = Encoding.UTF8.GetBytes(json);
126+
127+
return new MemoryStream(bytes);
128+
}
129+
130+
private static string GetTestDataPath()
131+
{
132+
var uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
133+
var workingDir = Path.GetDirectoryName(uri.LocalPath) ?? Directory.GetCurrentDirectory();
134+
135+
var baseDir = Path.Combine(workingDir, "Resources", "TestData");
136+
137+
return Path.GetFullPath(baseDir);
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)