-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathScanTests.cs
More file actions
75 lines (61 loc) · 2.26 KB
/
ScanTests.cs
File metadata and controls
75 lines (61 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.IO;
using System.Threading.Tasks;
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using NUnit.Framework;
namespace Aspose.BarCode.Cloud.Sdk.Tests
{
[TestFixture]
public class ScanTests : TestsBase
{
private IScanApi _api;
[SetUp]
public void Init()
{
_api = new ScanApi(TestConfiguration);
}
[Test]
public async Task ScanBase64AsyncTest()
{
// Arrange
using Stream image = GetTestImage("Test_PostGenerateMultiple.png");
byte[] buffer = new byte[image.Length];
_ = await image.ReadAsync(buffer, 0, buffer.Length);
// Act
BarcodeResponseList response = await _api.ScanBase64Async(
new ScanBase64Request()
{
FileBase64 = Convert.ToBase64String(buffer)
}
);
// Assert
Assert.AreEqual(2, response.Barcodes.Count);
Assert.AreEqual(DecodeBarcodeType.QR.ToString(), response.Barcodes[0].Type);
Assert.AreEqual("Hello world!", response.Barcodes[0].BarcodeValue);
}
[Test]
public async Task ScanAsyncTest()
{
// Act
BarcodeResponseList response = await _api.ScanAsync("https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png");
// Assert
Assert.AreEqual(1, response.Barcodes.Count);
Assert.AreEqual(DecodeBarcodeType.QR.ToString(), response.Barcodes[0].Type);
Assert.AreEqual("http://en.m.wikipedia.org", response.Barcodes[0].BarcodeValue);
}
[Test]
public async Task ScanMultipartAsyncTest()
{
// Arrange
using Stream image = GetTestImage("Test_PostGenerateMultiple.png");
// Act
BarcodeResponseList response = await _api.ScanMultipartAsync(image);
// Assert
Assert.AreEqual(2, response.Barcodes.Count);
Assert.AreEqual(DecodeBarcodeType.QR.ToString(), response.Barcodes[0].Type);
Assert.AreEqual("Hello world!", response.Barcodes[0].BarcodeValue);
}
}
}