Skip to content

Commit 8b4de8a

Browse files
authored
<TargetFramework>netstandard2.0</TargetFramework> (#33)
* Add new workflow for .Net Framework * Added tests for net461 and netcoreapp3.1. Switch from net45 to net461. * Build SDK with netstandard2.0 only * Add new badge to README.md
1 parent 54a1c2a commit 8b4de8a

24 files changed

+317
-234
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.cs]
8+
indent_style = space
9+
indent_size = 4
10+
11+
[Makefile]
12+
indent_style = tab

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
121
name: "CodeQL"
132

143
on:
154
push:
165
branches: [ master ]
176
pull_request:
18-
# The branches below must be a subset of the branches above
197
branches: [ master ]
20-
schedule:
21-
- cron: '44 17 * * 1'
228

239
jobs:
2410
analyze:

.github/workflows/dotnet-core.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
build:
10+
build-and-test:
1111

1212
runs-on: ubuntu-latest
1313

@@ -16,12 +16,12 @@ jobs:
1616
- name: Setup .NET Core
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 2.1.x
19+
dotnet-version: 3.1.x
20+
2021
- name: Install dependencies
2122
run: dotnet restore
22-
- name: Build
23-
run: dotnet build --configuration Release --no-restore --framework netcoreapp2.1
23+
2424
- name: Test
25-
run: dotnet test --no-restore --verbosity normal --framework netcoreapp2.1
25+
run: dotnet test --no-restore --verbosity normal --framework netcoreapp3.1
2626
env:
2727
TEST_CONFIGURATION_JWT_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: .NET Framework
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: [windows-latest]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup MSBuild
17+
uses: microsoft/setup-msbuild@v1
18+
19+
- name: Setup VSTest
20+
uses: darenm/Setup-VSTest@v1
21+
22+
- name: Build the Solution
23+
run: msbuild -restore -p:Configuration=Release
24+
25+
- name: Test with VSTest
26+
run: VSTest.Console.exe Tests\bin\Release\net461\Aspose.BarCode.Cloud.Sdk.Tests.dll
27+
env:
28+
TEST_CONFIGURATION_JWT_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}

Aspose.BarCode.Cloud.Sdk.sln

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2036
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.32106.194
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspose.BarCode.Cloud.Sdk", "src\Aspose.BarCode.Cloud.Sdk.csproj", "{56EA21EC-6AB0-452A-9826-62856992A33C}"
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspose.BarCode.Cloud.Sdk.Tests", "Tests\Aspose.BarCode.Cloud.Sdk.Tests.csproj", "{0E1CE574-E3A4-4F78-A6B5-C94D90E8EDCB}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D6335D67-21AD-403D-9866-8A3356A8CB2A}"
11+
ProjectSection(SolutionItems) = preProject
12+
.editorconfig = .editorconfig
13+
EndProjectSection
14+
EndProject
1015
Global
1116
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1217
Debug|Any CPU = Debug|Any CPU

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ all: test
33

44
.PHONY: format
55
format:
6-
dotnet format
6+
dotnet format ./Aspose.BarCode.Cloud.Sdk.sln
77

88
.PHONY: test
99
test:

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
| ---------------------------------------------------------------------------------------------- |
55

66
[![License](https://img.shields.io/github/license/aspose-barcode-cloud/aspose-barcode-cloud-dotnet)](LICENSE)
7-
[![.NET Core](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/dotnet-core.yml/badge.svg)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/dotnet-core.yml)
7+
[![.NET Core](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/dotnet-core.yml/badge.svg?branch=master)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/dotnet-core.yml)
8+
[![.NET Framework](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/net-framework.yml/badge.svg?branch=master)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dotnet/actions/workflows/net-framework.yml)
89
[![Nuget](https://img.shields.io/nuget/v/Aspose.BarCode-Cloud)](https://www.nuget.org/packages/Aspose.BarCode-Cloud/)
910

1011
- API version: 3.0
11-
- SDK version: 22.1.0
12+
- SDK version: 22.1.1
1213

1314
## Demo applications
1415

Tests/ApiExceptionTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public class ApiExceptionTests : TestsBase
1212
public void GetBarcodeGenerateTestThrows()
1313
{
1414
// Arrange
15-
var config = new Configuration();
16-
var api = new BarcodeApi(config);
15+
var api = new BarcodeApi(clientId: "client id", clientSecret: "client secret");
1716
var request = new GetBarcodeGenerateRequest(
1817
text: "Very sample text",
1918
type: EncodeBarcodeType.Code128.ToString(),
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
6-
<IsPackable>false</IsPackable>
4+
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
5+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6+
<IsTestProject>true</IsTestProject>
7+
<LangVersion>8.0</LangVersion>
78
</PropertyGroup>
8-
9+
<ItemGroup>
10+
<Compile Remove="TestResults\**" />
11+
<EmbeddedResource Remove="TestResults\**" />
12+
<None Remove="TestResults\**" />
13+
</ItemGroup>
914
<ItemGroup>
1015
<PackageReference Include="Moq" Version="4.14.2" />
11-
<PackageReference Include="nunit" Version="3.12.0" />
16+
<PackageReference Include="NUnit" Version="3.12.0" />
1217
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
1318
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
1419
</ItemGroup>
15-
1620
<ItemGroup>
1721
<ProjectReference Include="..\src\Aspose.BarCode.Cloud.Sdk.csproj" />
1822
</ItemGroup>
19-
2023
</Project>

Tests/BarcodeApiTests.cs

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class BarcodeApiTests : TestsBase
2626
public void Init()
2727
{
2828
_api = new BarcodeApi(TestConfiguration);
29+
_fileApi = new FileApi(TestConfiguration);
2930
}
3031

3132
/// <summary>
@@ -37,25 +38,20 @@ public void Cleanup()
3738
}
3839

3940
private IBarcodeApi _api;
41+
private IFileApi _fileApi;
4042

41-
private static string PutTestFile(IBarcodeApi api, string fileName, List<GeneratorParams> barcodes)
43+
private string PutTestFile(string fileName)
4244
{
43-
var generatorParamsList = new GeneratorParamsList
44-
{
45-
BarcodeBuilders = barcodes
46-
};
47-
48-
var folder = TempFolderPath;
49-
var request = new PutGenerateMultipleRequest(
50-
fileName,
51-
generatorParamsList,
52-
folder: folder
45+
using FileStream fileToUpload = File.Open(TestFilePath(fileName), FileMode.Open, FileAccess.Read);
46+
FilesUploadResult uploaded = _fileApi.UploadFile(
47+
new UploadFileRequest(
48+
$"{TempFolderPath}/{fileName}",
49+
fileToUpload
50+
)
5351
);
52+
Assert.IsNotEmpty(uploaded.Uploaded);
5453

55-
ResultImageInfo response = api.PutGenerateMultiple(request);
56-
Assert.IsTrue(response.FileSize > 0);
57-
58-
return folder;
54+
return TempFolderPath;
5955
}
6056

6157

@@ -73,17 +69,14 @@ public void GetBarcodeGenerateTest()
7369
);
7470

7571
// Act
76-
using (Stream response = _api.GetBarcodeGenerate(request))
77-
{
78-
// Assert
79-
Assert.IsTrue(response.Length > 0);
80-
using (FileStream stream = File.Create(TestFilePath("Test_GetBarcodeGenerate.png")))
81-
{
82-
response.CopyTo(stream);
83-
}
84-
}
72+
using Stream response = _api.GetBarcodeGenerate(request);
73+
// Assert
74+
Assert.IsTrue(response.Length > 0);
75+
using FileStream savedFileStream = File.Create(TestFilePath("Test_GetBarcodeGenerate.png"));
76+
response.CopyTo(savedFileStream);
8577
}
8678

79+
8780
/// <summary>
8881
/// Test GetBarcodeRecognize
8982
/// </summary>
@@ -105,8 +98,8 @@ public void GetBarcodeRecognizeTest()
10598
}
10699
};
107100

108-
const string fileName = "Test_GetBarcodeRecognize.png";
109-
var folder = PutTestFile(_api, fileName, barcodesToRecognize);
101+
const string fileName = "Test_PostGenerateMultiple.png";
102+
string folder = PutTestFile(fileName);
110103
var request = new GetBarcodeRecognizeRequest(
111104
fileName,
112105
folder: folder,
@@ -128,6 +121,7 @@ public void GetBarcodeRecognizeTest()
128121
}
129122
}
130123

124+
131125
/// <summary>
132126
/// Test an instance of BarcodeApi
133127
/// </summary>
@@ -137,6 +131,7 @@ public void InstanceTest()
137131
Assert.IsInstanceOf(typeof(IBarcodeApi), _api, "instance is a IBarcodeApi");
138132
}
139133

134+
140135
/// <summary>
141136
/// Test PostBarcodeRecognizeFromUrlOrContent
142137
/// </summary>
@@ -163,6 +158,7 @@ public void PostBarcodeRecognizeFromUrlOrContentTest()
163158
Assert.AreEqual("1234567812", response.Barcodes[0].BarcodeValue);
164159
}
165160

161+
166162
/// <summary>
167163
/// Test PostGenerateMultiple
168164
/// </summary>
@@ -190,18 +186,15 @@ public void PostGenerateMultipleTest()
190186
);
191187

192188
// Act
193-
using (Stream response = _api.PostGenerateMultiple(request))
194-
{
195-
// Assert
189+
using Stream response = _api.PostGenerateMultiple(request);
190+
// Assert
196191

197-
Assert.IsTrue(response.Length > 0);
198-
using (FileStream stream = File.Create(TestFilePath("Test_PostGenerateMultiple.png")))
199-
{
200-
response.CopyTo(stream);
201-
}
202-
}
192+
Assert.IsTrue(response.Length > 0);
193+
using FileStream savedFileStream = File.Create(TestFilePath("Test_PostGenerateMultiple.png"));
194+
response.CopyTo(savedFileStream);
203195
}
204196

197+
205198
/// <summary>
206199
/// Test PutBarcodeGenerateFile
207200
/// </summary>
@@ -225,6 +218,7 @@ public void PutBarcodeGenerateFileTest()
225218
Assert.True(response.ImageHeight > 0);
226219
}
227220

221+
228222
/// <summary>
229223
/// Test PutBarcodeRecognizeFromBody
230224
/// </summary>
@@ -234,20 +228,15 @@ public void PutBarcodeRecognizeFromBodyTest()
234228
// Arrange
235229
var barcodesToRecognize = new List<GeneratorParams>
236230
{
237-
new GeneratorParams
238-
{
239-
TypeOfBarcode = EncodeBarcodeType.QR,
240-
Text = "PutBarcodeRecognizeFromBody QR"
241-
},
242231
new GeneratorParams
243232
{
244233
TypeOfBarcode = EncodeBarcodeType.Code128,
245-
Text = "PutBarcodeRecognizeFromBody Code128"
234+
Text = "Very sample text"
246235
}
247236
};
248237

249-
const string fileName = "Test_PutBarcodeRecognizeFromBody.png";
250-
var folder = PutTestFile(_api, fileName, barcodesToRecognize);
238+
const string fileName = "Test_GetBarcodeGenerate.png";
239+
string folder = PutTestFile(fileName);
251240

252241
var request = new PutBarcodeRecognizeFromBodyRequest(
253242
fileName,
@@ -273,6 +262,7 @@ public void PutBarcodeRecognizeFromBodyTest()
273262
}
274263
}
275264

265+
276266
/// <summary>
277267
/// Test PutGenerateMultiple
278268
/// </summary>

0 commit comments

Comments
 (0)