Skip to content

Commit 8e8e7c5

Browse files
Add WebClient test project
1 parent 71561a6 commit 8e8e7c5

File tree

4 files changed

+4664
-0
lines changed

4 files changed

+4664
-0
lines changed

Regula.DocumentReader.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ VisualStudioVersion = 16.0.30503.244
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Regula.DocumentReader.WebClient", "src\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj", "{21FC9582-EA65-4043-ABF6-BD436E3CCD10}"
66
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Regula.DocumentReader.WebClientTest", "src\Regula.DocumentReader.WebClientTest\Regula.DocumentReader.WebClientTest.csproj", "{3B5A6175-62E1-4A21-A16A-194C9C67D86B}"
8+
EndProject
79
Global
810
GlobalSection(SolutionConfigurationPlatforms) = preSolution
911
Debug|Any CPU = Debug|Any CPU
@@ -14,6 +16,10 @@ Global
1416
{21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Debug|Any CPU.Build.0 = Debug|Any CPU
1517
{21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Release|Any CPU.ActiveCfg = Release|Any CPU
1618
{21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{3B5A6175-62E1-4A21-A16A-194C9C67D86B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{3B5A6175-62E1-4A21-A16A-194C9C67D86B}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{3B5A6175-62E1-4A21-A16A-194C9C67D86B}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{3B5A6175-62E1-4A21-A16A-194C9C67D86B}.Release|Any CPU.Build.0 = Release|Any CPU
1723
EndGlobalSection
1824
GlobalSection(SolutionProperties) = preSolution
1925
HideSolutionNode = FALSE
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="JsonSubTypes" Version="1.7.0" />
11+
<PackageReference Include="nunit" Version="3.12.0" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<None Update="response.json">
18+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
19+
</None>
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<ProjectReference Include="..\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj" />
24+
</ItemGroup>
25+
26+
</Project>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.IO;
2+
using Newtonsoft.Json;
3+
using NUnit.Framework;
4+
using Regula.DocumentReader.WebClient.Model;
5+
using Regula.DocumentReader.WebClient.Model.Ext;
6+
7+
namespace Regula.DocumentReader.WebClientTest
8+
{
9+
public class ResponseTest
10+
{
11+
[Test]
12+
public void ShouldProcessValidResponse()
13+
{
14+
var response = GetResponseFromFile("response.json");
15+
16+
Assert.AreEqual(CheckResult.ERROR, response.Status().OverallStatus);
17+
Assert.AreEqual(CheckResult.ERROR, response.Status().DetailsOptical.Text);
18+
19+
var docNumber = response.Text().GetField(TextFieldType.DOCUMENT_NUMBER);
20+
Assert.AreEqual("U0996738", docNumber.Value);
21+
Assert.AreEqual("U0996738", docNumber.GetValue(Source.VISUAL));
22+
Assert.AreEqual("U0996738", docNumber.GetValue(Source.MRZ));
23+
Assert.AreEqual(2, docNumber.SourceValidity(Source.VISUAL));
24+
Assert.AreEqual(1, docNumber.SourceValidity(Source.MRZ));
25+
Assert.AreEqual(1, docNumber.CrossSourceComparison(Source.MRZ, Source.VISUAL));
26+
}
27+
28+
[Test]
29+
public void ShouldProcessRawResultType()
30+
{
31+
Assert.Fail();
32+
}
33+
34+
private static RecognitionResponse GetResponseFromFile(string fileName)
35+
{
36+
string responseJson = File.ReadAllText(fileName);
37+
38+
var processResponse = JsonConvert.DeserializeObject<ProcessResponse>(responseJson, new JsonSerializerSettings
39+
{
40+
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
41+
});
42+
43+
var response = new RecognitionResponse(processResponse);
44+
return response;
45+
}
46+
}
47+
}

src/Regula.DocumentReader.WebClientTest/response.json

Lines changed: 4585 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)