-
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 #47 from getyoti/Release/1.5.0
Release v1.5.0
- Loading branch information
Showing
36 changed files
with
845 additions
and
119 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
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
129 changes: 129 additions & 0 deletions
129
...h.Sandbox.Tests/DocScan/Request/Check/SandboxSupplementaryDocTextDataCheckBuilderTests.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,129 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Check; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Check.Report; | ||
|
||
namespace Yoti.Auth.Sandbox.Tests.DocScan.Request.Check | ||
{ | ||
public class SandboxSupplementaryDocTextDataCheckBuilderTests | ||
{ | ||
private readonly SandboxBreakdown _someBreakDown = new SandboxBreakdown("someSubCheck", "someResult", details: null); | ||
private readonly SandboxRecommendation _someRecommendation = new SandboxRecommendation("someValue", "someReason", "someRecoverySuggestion"); | ||
private readonly string _someKey = "someName"; | ||
private readonly string _someValue = "someValue"; | ||
|
||
[Fact] | ||
public void ShouldNotBuildWithoutRecommendation() | ||
{ | ||
var exception = Assert.Throws<ArgumentNullException>(() => | ||
{ | ||
new SandboxSupplementaryDocTextDataCheckBuilder() | ||
.WithDocumentField("key", "value") | ||
.WithBreakdown(_someBreakDown) | ||
.Build(); | ||
}); | ||
|
||
Assert.Contains("Recommendation", exception.Message, StringComparison.Ordinal); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithDocumentField() | ||
{ | ||
var check = new SandboxSupplementaryDocTextDataCheckBuilder() | ||
.WithDocumentField(_someKey, _someValue) | ||
.WithBreakdown(_someBreakDown) | ||
.WithRecommendation(_someRecommendation) | ||
.Build(); | ||
|
||
var sandboxTextDataCheckResult = (SandboxSupplementaryDocTextDataCheckResult)check.Result; | ||
|
||
var result = sandboxTextDataCheckResult.DocumentFields.Single(); | ||
|
||
Assert.Equal(_someKey, result.Key); | ||
Assert.Equal(_someValue, result.Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithoutDocumentFields() | ||
{ | ||
var check = new SandboxSupplementaryDocTextDataCheckBuilder() | ||
.WithBreakdown(_someBreakDown) | ||
.WithRecommendation(_someRecommendation) | ||
.Build(); | ||
|
||
var sandboxTextDataCheckResult = (SandboxSupplementaryDocTextDataCheckResult)check.Result; | ||
|
||
Assert.Null(sandboxTextDataCheckResult.DocumentFields); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithDocumentFields() | ||
{ | ||
var documentFields = new Dictionary<string, object> | ||
{ | ||
{ _someKey, _someValue }, | ||
{ "key2", "value2" } | ||
}; | ||
|
||
var check = new SandboxSupplementaryDocTextDataCheckBuilder() | ||
.WithDocumentFields(documentFields) | ||
.WithRecommendation(_someRecommendation) | ||
.WithBreakdown(_someBreakDown) | ||
.Build(); | ||
|
||
var sandboxTextDataCheckResult = (SandboxSupplementaryDocTextDataCheckResult)check.Result; | ||
|
||
var result = sandboxTextDataCheckResult.DocumentFields; | ||
|
||
Assert.Equal(2, result.Count); | ||
Assert.Equal(_someKey, result.ElementAt(0).Key); | ||
Assert.Equal(_someValue, result.ElementAt(0).Value); | ||
Assert.Equal("key2", result.ElementAt(1).Key); | ||
Assert.Equal("value2", result.ElementAt(1).Value); | ||
} | ||
|
||
[Fact] | ||
public void WithDocumentFieldsShouldOverrideWithDocumentField() | ||
{ | ||
var documentFields = new Dictionary<string, object> | ||
{ | ||
{ _someKey, _someValue }, | ||
{ "key2", _someValue } | ||
}; | ||
|
||
var check = new SandboxSupplementaryDocTextDataCheckBuilder() | ||
.WithDocumentField(_someKey, _someValue) | ||
.WithDocumentFields(documentFields) | ||
.WithRecommendation(_someRecommendation) | ||
.WithBreakdown(_someBreakDown) | ||
.Build(); | ||
|
||
var sandboxTextDataCheckResult = (SandboxSupplementaryDocTextDataCheckResult)check.Result; | ||
|
||
Assert.Equal(2, sandboxTextDataCheckResult.DocumentFields.Count); | ||
} | ||
|
||
[Fact] | ||
public void WithDocumentFieldShouldAddToDocumentFields() | ||
{ | ||
var documentFields = new Dictionary<string, object> | ||
{ | ||
{ "key1", _someValue }, | ||
{ "key2", _someValue } | ||
}; | ||
|
||
var check = new SandboxSupplementaryDocTextDataCheckBuilder() | ||
.WithDocumentFields(documentFields) | ||
.WithDocumentField(_someKey, _someValue) | ||
.WithBreakdown(_someBreakDown) | ||
.WithRecommendation(_someRecommendation) | ||
.Build(); | ||
|
||
var sandboxTextDataCheckResult = (SandboxSupplementaryDocTextDataCheckResult)check.Result; | ||
|
||
Assert.Equal(3, sandboxTextDataCheckResult.DocumentFields.Count); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Yoti.Auth.Sandbox.Tests/DocScan/Request/Task/SandboxDocumentTextDataExtractionReasonTests.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,43 @@ | ||
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 SandboxDocumentTextDataExtractionReasonTests | ||
{ | ||
private readonly string _someReasonDetail = "someReasonDetail"; | ||
|
||
[Fact] | ||
public void ShouldBuildForQuality() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionReasonBuilder() | ||
.ForQuality() | ||
.Build(); | ||
|
||
Assert.Equal("QUALITY", task.Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildForUserError() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionReasonBuilder() | ||
.ForUserError() | ||
.Build(); | ||
|
||
Assert.Equal("USER_ERROR", task.Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildForAReasonDetail() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionReasonBuilder() | ||
.WithDetail(_someReasonDetail) | ||
.Build(); | ||
|
||
Assert.Equal(_someReasonDetail, task.Detail); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...andbox.Tests/DocScan/Request/Task/SandboxDocumentTextDataExtractionRecommendationTests.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,50 @@ | ||
using Xunit; | ||
using Yoti.Auth.Sandbox.DocScan.Request.Task; | ||
|
||
namespace Yoti.Auth.Sandbox.Tests.DocScan.Request.Task | ||
{ | ||
public class SandboxDocumentTextDataExtractionRecommendationTests | ||
{ | ||
[Fact] | ||
public void ShouldBuildWithRecommendationForProgress() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionRecommendationBuilder() | ||
.ForProgress() | ||
.Build(); | ||
|
||
Assert.Equal("PROGRESS", task.Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithRecommendationShouldTryAgain() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionRecommendationBuilder() | ||
.ForShouldTryAgain() | ||
.Build(); | ||
|
||
Assert.Equal("SHOULD_TRY_AGAIN", task.Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithRecommendationMustTryAgain() | ||
{ | ||
var task = new SandboxDocumentTextDataExtractionRecommendationBuilder() | ||
.ForMustTryAgain() | ||
.Build(); | ||
|
||
Assert.Equal("MUST_TRY_AGAIN", task.Value); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBuildWithReason() | ||
{ | ||
SandboxDocumentTextDataExtractionReason _someReason = new SandboxDocumentTextDataExtractionReason("value", "details"); | ||
|
||
var task = new SandboxDocumentTextDataExtractionRecommendationBuilder() | ||
.WithReason(_someReason) | ||
.Build(); | ||
|
||
Assert.Equal(_someReason, task.Reason); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.