-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from getyoti/Release/1.4.0
Release/1.4.0
- Loading branch information
Showing
24 changed files
with
537 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: local-dotnet-test | ||
name: 'Run unit tests' | ||
entry: test.sh | ||
language: 'script' | ||
description: "Run unit tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
....Auth.Sandbox.Tests/DocScan/Request/Check/SandboxIdDocumentComparisonCheckBuilderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Linq; | ||
using Xunit; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Check; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Check.Report; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Task; | ||
|
||
namespace Yoti.Auth.Sandbox.Tests.DocScan.Request.Check | ||
{ | ||
public class SandboxIdDocumentComparisonCheckBuilderTests | ||
{ | ||
[Fact] | ||
public void ShouldBuildWithOnlyRecommendation() | ||
{ | ||
var idDocComparisonCheck = new SandboxIdDocumentComparisonCheckBuilder() | ||
.WithRecommendation( | ||
new SandboxRecommendationBuilder() | ||
.WithValue("APPROVE") | ||
.Build()) | ||
.Build(); | ||
|
||
Assert.Equal("APPROVE", idDocComparisonCheck.Result.Report.Recommendation.Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithSecondaryDocumentFilter() | ||
{ | ||
var idDocComparisonCheck = new SandboxIdDocumentComparisonCheckBuilder() | ||
.WithRecommendation( | ||
new SandboxRecommendationBuilder() | ||
.WithValue("APPROVE") | ||
.Build()) | ||
.WithSecondaryDocumentFilter( | ||
new SandboxDocumentFilterBuilder() | ||
.WithCountryCode("GBR") | ||
.Build()) | ||
.Build(); | ||
|
||
Assert.Equal("GBR", idDocComparisonCheck.SecondaryDocumentFilter.CountryCodes.Single()); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
Yoti.Auth.Sandbox.Tests/DocScan/Request/Task/SandboxDocumentFilterBuilderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Task; | ||
|
||
namespace Yoti.Auth.Sandbox.Tests.DocScan.Request.Task | ||
{ | ||
public class SandboxDocumentFilterBuilderTests | ||
{ | ||
private readonly string _country1 = "CR1"; | ||
private readonly string _country2 = "CR2"; | ||
private readonly string _documentType1 = "DOCUMENT_TYPE_1"; | ||
private readonly string _documentType2 = "DOCUMENT_TYPE_2"; | ||
|
||
[Fact] | ||
public void ShouldBuildSandboxDocumentFilterWithCountryCode() | ||
{ | ||
var filter = new SandboxDocumentFilterBuilder() | ||
.WithCountryCode(_country1) | ||
.Build(); | ||
|
||
Assert.Equal(_country1, filter.CountryCodes.Single()); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildSandboxDocumentFilteMultipleWithCountryCodes() | ||
{ | ||
var filter = new SandboxDocumentFilterBuilder() | ||
.WithCountryCode(_country1) | ||
.WithCountryCode(_country2) | ||
.Build(); | ||
|
||
Assert.Equal(new List<string> { _country1, _country2 }, filter.CountryCodes); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildSandboxDocumentFilterWithCountryCodes() | ||
{ | ||
var countryCodes = new List<string> { _country1, _country2 }; | ||
|
||
var filter = new SandboxDocumentFilterBuilder() | ||
.WithCountryCodes(countryCodes) | ||
.Build(); | ||
|
||
Assert.Equal(countryCodes, filter.CountryCodes); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildSandboxDocumentFilterWithDocumentType() | ||
{ | ||
var filter = new SandboxDocumentFilterBuilder() | ||
.WithDocumentType(_country1) | ||
.Build(); | ||
|
||
Assert.Equal(_country1, filter.DocumentTypes.Single()); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildSandboxDocumentFilterMultipleWithDocumentTypes() | ||
{ | ||
var filter = new SandboxDocumentFilterBuilder() | ||
.WithDocumentType(_documentType1) | ||
.WithDocumentType(_documentType2) | ||
.Build(); | ||
|
||
Assert.Equal(new List<string> { _documentType1, _documentType2 }, filter.DocumentTypes); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildSandboxDocumentFilterWithDocumentTypes() | ||
{ | ||
var documentTypes = new List<string> { _documentType1, _documentType2 }; | ||
|
||
var filter = new SandboxDocumentFilterBuilder() | ||
.WithDocumentTypes(documentTypes) | ||
.Build(); | ||
|
||
Assert.Equal(documentTypes, filter.DocumentTypes); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...th.Sandbox.Tests/DocScan/Request/Task/SandboxDocumentTextDataExtractionTaskBuilderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Task; | ||
|
||
namespace Yoti.Auth.Sandbox.Tests.DocScan.Request.Task | ||
{ | ||
public class SandboxDocumentTextDataExtractionTaskBuilderTest | ||
{ | ||
private readonly string _someKey = "someKey"; | ||
private readonly string _someValue = "someValue"; | ||
private readonly string _someOtherKey = "someOtherKey"; | ||
private readonly string _someOtherValue = "someOtherValue"; | ||
|
||
[Fact] | ||
public void ShouldBuildWithDocumentField() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionTaskBuilder() | ||
.WithDocumentField(_someKey, _someValue) | ||
.Build(); | ||
|
||
Assert.Equal(_someValue, task.Result.DocumentFields[_someKey]); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithDocumentFieldMultiple() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionTaskBuilder() | ||
.WithDocumentField(_someKey, _someValue) | ||
.WithDocumentField(_someOtherKey, _someOtherValue) | ||
.Build(); | ||
|
||
Assert.Equal(_someValue, task.Result.DocumentFields[_someKey]); | ||
Assert.Equal(_someOtherValue, task.Result.DocumentFields[_someOtherKey]); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithDocumentFields() | ||
{ | ||
var documentFields = new Dictionary<string, object> | ||
{ | ||
{ _someKey, _someValue }, | ||
{ _someOtherKey, _someOtherValue } | ||
}; | ||
|
||
var task = new SandboxDocumentTextDataExtractionTaskBuilder() | ||
.WithDocumentFields(documentFields) | ||
.Build(); | ||
|
||
Assert.Equal(_someValue, task.Result.DocumentFields[_someKey]); | ||
Assert.Equal(_someOtherValue, task.Result.DocumentFields[_someOtherKey]); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithoutMethods() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionTaskBuilder().Build(); | ||
|
||
Assert.Null(task.Result.DocumentFields); | ||
Assert.Null(task.Result.DocumentIdPhoto); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithDocumentIdPhoto() | ||
{ | ||
byte[] imageBytes = Encoding.UTF8.GetBytes("someImage"); | ||
string contentType = "image/jpeg"; | ||
|
||
var task = new SandboxDocumentTextDataExtractionTaskBuilder() | ||
.WithDocumentIdPhoto(contentType, imageBytes) | ||
.Build(); | ||
|
||
Assert.Equal(contentType, task.Result.DocumentIdPhoto.ContentType); | ||
Assert.Equal(Convert.ToBase64String(imageBytes), task.Result.DocumentIdPhoto.Base64Data); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
Yoti.Auth.Sandbox.Tests/DocScan/SandboxCheckReportsBuilderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Linq; | ||
using Xunit; | ||
using Yoti.Auth.Sandbox.DocScan.Request; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Check; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Check.Report; | ||
|
||
namespace Yoti.Auth.Sandbox.Tests.DocScan | ||
{ | ||
public static class SandboxCheckReportsBuilderTests | ||
{ | ||
[Fact] | ||
public static void BuilderShouldBuildWithAllArguments() | ||
{ | ||
var sandboxCheckReport = new SandboxCheckReportsBuilder() | ||
.WithAsyncReportDelay(10) | ||
.WithDocumentAuthenticityCheck( | ||
new SandboxDocumentAuthenticityCheckBuilder() | ||
.WithRecommendation( | ||
new SandboxRecommendationBuilder() | ||
.WithValue("NOT_AVAILABLE") | ||
.WithReason("PICTURE_TOO_DARK") | ||
.WithRecoverySuggestion("BETTER_LIGHTING") | ||
.Build()) | ||
.Build()) | ||
.WithDocumentFaceMatchCheck( | ||
new SandboxDocumentFaceMatchCheckBuilder() | ||
.WithRecommendation( | ||
new SandboxRecommendationBuilder() | ||
.WithValue("APPROVE") | ||
.Build()) | ||
.Build()) | ||
.WithDocumentTextDataCheck( | ||
new SandboxDocumentTextDataCheckBuilder() | ||
.WithRecommendation( | ||
new SandboxRecommendationBuilder() | ||
.WithValue("APPROVE") | ||
.Build()) | ||
.Build()) | ||
.WithLivenessCheck( | ||
new SandboxZoomLivenessCheckBuilder() | ||
.WithRecommendation( | ||
new SandboxRecommendationBuilder() | ||
.WithValue("APPROVE") | ||
.Build()) | ||
.Build()) | ||
.WithIdDocumentComparisonCheck( | ||
new SandboxIdDocumentComparisonCheckBuilder() | ||
.WithRecommendation( | ||
new SandboxRecommendationBuilder() | ||
.WithValue("APPROVE") | ||
.Build()) | ||
.Build()) | ||
.Build(); | ||
|
||
Assert.Equal(10, sandboxCheckReport.AsyncReportDelay); | ||
Assert.NotNull(sandboxCheckReport.DocumentAuthenticityCheck); | ||
Assert.NotNull(sandboxCheckReport.DocumentFaceMatchCheck); | ||
Assert.NotNull(sandboxCheckReport.TextDataCheck); | ||
Assert.Equal("ZOOM", sandboxCheckReport.LivenessChecks.Single().LivenessType); | ||
Assert.NotNull(sandboxCheckReport.IdDocumentComparisonChecks); | ||
} | ||
} | ||
} |
Oops, something went wrong.