public static void ShouldCreateRequestWithMultipleAgeVerifications() { SandboxAgeVerification ageOver = SandboxAgeVerification.Builder() .WithDateOfBirth(_dobOver18) .WithAgeOver(18) .Build(); SandboxAgeVerification ageUnder = SandboxAgeVerification.Builder() .WithDateOfBirth(_dobOver18) .WithAgeUnder(18) .Build(); YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder() .WithAgeVerification(ageOver) .WithAgeVerification(ageUnder) .Build(); ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes; Assert.True(result.Count == 2); AttributeMatcher.AssertContainsDerivedAttribute( result, Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute, _dobOver18, "age_over:18"); AttributeMatcher.AssertContainsDerivedAttribute( result, Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute, _dobOver18, "age_under:18"); }
public static void ShouldParseDateOfBirthSuccessfully() { SandboxAgeVerification result = SandboxAgeVerification.Builder() .WithDateOfBirth(_validDateString) .WithAgeOver(7) .Build(); Assert.Equal(_validDateString, result.ToAttribute().Value); }
public static void ShouldErrorForMissingDerivation() { var exception = Assert.Throws <InvalidOperationException>(() => { SandboxAgeVerification.Builder() .WithDateOfBirth(_validDateString) .Build(); }); Assert.Contains("'supportedAgeDerivation' must not be empty or null", exception.Message, StringComparison.Ordinal); }
public static void ShouldErrorForNullAnchors() { var exception = Assert.Throws <ArgumentNullException>(() => { SandboxAgeVerification.Builder() .WithAnchors(null); }); Assert.Contains("Value cannot be null.", exception.Message, StringComparison.Ordinal); Assert.Contains("Parameter 'anchors'", exception.Message, StringComparison.Ordinal); }
public static void ShouldErrorForBadDateOfBirth() { var exception = Assert.Throws <InvalidCastException>(() => { SandboxAgeVerification.Builder() .WithDateOfBirth("2011-15-35") .Build(); }); Assert.Contains("Error when converting string value '2011-15-35' to a DateTime", exception.Message, StringComparison.Ordinal); }
public static void ShouldErrorForMissingDateOfBirth() { var exception = Assert.Throws <InvalidOperationException>(() => { SandboxAgeVerification.Builder() .Build(); }); Assert.Contains( "the value of 'dateOfBirth' must not be equal to the default value for 'System.DateTime'", exception.Message, StringComparison.Ordinal); }
public static void ShouldCreateAgeUnderSandboxAttribute() { SandboxAttribute result = SandboxAgeVerification.Builder() .WithDateOfBirth(_validDateString) .WithAgeUnder(16) .Build() .ToAttribute(); Assert.Equal(Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute, result.Name); Assert.Equal(_validDateString, result.Value); Assert.Equal($"{Yoti.Auth.Constants.UserProfile.AgeUnderAttribute}:{16}", result.Derivation); #pragma warning disable 0618 Assert.Equal("False", result.Optional); //NOSONAR #pragma warning restore 0618 Assert.Empty(result.Anchors); }