public void ShouldOverwriteIdenticalAgeVerificationToEnsureItOnlyExistsOnce()
        {
            DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder()
                                          .WithAgeUnder(30)
                                          .WithAgeUnder(30)
                                          .Build();

            ICollection <WantedAttribute> result = dynamicPolicy.WantedAttributes;
            var attributeMatcher = new WantedAttributeMatcher(result);

            Assert.AreEqual(1, result.Count);

            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute, derivation: $"{UserProfile.AgeUnderAttribute}:{30}"));
        }
        public void ShouldBuildWithMultipleAgeDerivedAttributes()
        {
            DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder()
                                          .WithDateOfBirth()
                                          .WithAgeOver(18)
                                          .WithAgeUnder(30)
                                          .WithAgeUnder(40)
                                          .Build();

            ICollection <WantedAttribute> result = dynamicPolicy.WantedAttributes;
            var attributeMatcher = new WantedAttributeMatcher(result);

            Assert.AreEqual(4, result.Count);

            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute, derivation: $"{UserProfile.AgeOverAttribute}:{18}"));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute, derivation: $"{UserProfile.AgeUnderAttribute}:{30}"));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute, derivation: $"{UserProfile.AgeUnderAttribute}:{40}"));
        }
        public void ShouldContainAllAddedAttributes()
        {
            DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder()
                                          .WithFamilyName()
                                          .WithGivenNames()
                                          .WithFullName()
                                          .WithDateOfBirth()
                                          .WithGender()
                                          .WithPostalAddress()
                                          .WithStructuredPostalAddress()
                                          .WithNationality()
                                          .WithPhoneNumber()
                                          .WithSelfie()
                                          .WithEmail()
                                          .WithDocumentDetails()
                                          .WithDocumentImages()
                                          .WithAgeOver(55)
                                          .WithAgeUnder(18)
                                          .Build();

            ICollection <WantedAttribute> result = dynamicPolicy.WantedAttributes;
            var attributeMatcher = new WantedAttributeMatcher(result);

            Assert.AreEqual(15, result.Count);

            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.FamilyNameAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.GivenNamesAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.FullNameAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.GenderAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.PostalAddressAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.StructuredPostalAddressAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.NationalityAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.PhoneNumberAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.SelfieAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.EmailAddressAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DocumentImagesAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DocumentDetailsAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute, derivation: $"{Constants.UserProfile.AgeOverAttribute}:55"));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DateOfBirthAttribute, derivation: $"{Constants.UserProfile.AgeUnderAttribute}:18"));
        }
        public void ShouldAddMultipleAttributesWithSameNameAndDifferentConstraints()
        {
            var passportConstraint = new SourceConstraintBuilder()
                                     .WithPassport()
                                     .Build();

            var docImage1 = new WantedAttributeBuilder()
                            .WithName(Yoti.Auth.Constants.UserProfile.DocumentImagesAttribute)
                            .WithConstraint(passportConstraint)
                            .Build();

            var drivingLicenseConstraint = new SourceConstraintBuilder()
                                           .WithDrivingLicense()
                                           .Build();

            var docImage2 = new WantedAttributeBuilder()
                            .WithName(Yoti.Auth.Constants.UserProfile.DocumentImagesAttribute)
                            .WithConstraints(new List <Constraint> {
                drivingLicenseConstraint
            })
                            .Build();

            DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder()
                                          .WithWantedAttribute(docImage1)
                                          .WithWantedAttribute(docImage2)
                                          .Build();

            ICollection <WantedAttribute> result = dynamicPolicy.WantedAttributes;
            var attributeMatcher = new WantedAttributeMatcher(result);

            Assert.AreEqual(2, result.Count);

            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DocumentImagesAttribute, null, new List <Constraint> {
                passportConstraint
            }));
            Assert.IsTrue(attributeMatcher.ContainsAttribute(UserProfile.DocumentImagesAttribute, null, new List <Constraint> {
                drivingLicenseConstraint
            }));
        }