public void TestGetNameDelegate()
        {
            var state       = "TN";
            var mailAddress = new AddressDTO();

            mailAddress.Country    = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME;
            mailAddress.Division   = state;
            mailAddress.Street1    = "street1";
            mailAddress.PostalCode = "11111";

            var usAddress = new AddressDTO();

            usAddress.Country    = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME;
            usAddress.Division   = state;
            usAddress.Street1    = "street2";
            usAddress.PostalCode = "22222";

            string   birthCity              = "birth city";
            string   birthCountryCode       = "US";
            var      birthCountryReasonCode = USBornReasonType.Item01.ToString();
            DateTime birthDate              = DateTime.Now;
            string   citizenshipCountryCode = "UK";
            string   emailAddress           = "*****@*****.**";

            var firstName = "first";
            var lastName  = "last";
            var passport  = "passport";
            var preferred = "preferred";
            var suffix    = "Jr.";
            var fullName  = new FullName(firstName, lastName, passport, preferred, suffix);

            string gender = Gender.SEVIS_FEMALE_GENDER_CODE_VALUE;
            string permanentResidenceCountryCode = "FR";
            string phoneNumber  = "18505551212";
            string relationship = "relations";
            var    isTravelingWithParticipant = true;
            var    isDeleted = false;
            Func <AddedDependent> createEntity = () =>
            {
                return(new AddedDependent(
                           fullName: fullName,
                           birthCity: birthCity,
                           birthCountryCode: birthCountryCode,
                           birthCountryReasonCode: birthCountryReasonCode,
                           birthDate: birthDate,
                           citizenshipCountryCode: citizenshipCountryCode,
                           emailAddress: emailAddress,
                           gender: gender,
                           permanentResidenceCountryCode: permanentResidenceCountryCode,
                           phoneNumber: phoneNumber,
                           relationship: relationship,
                           mailAddress: mailAddress,
                           usAddress: usAddress,
                           printForm: true,
                           isTravelingWithParticipant: isTravelingWithParticipant,
                           personId: 10,
                           participantId: 20,
                           isDeleted: isDeleted));
            };

            var validator = new DependentValidator();
            var d         = validator.GetNameDelegate();

            Assert.AreEqual(string.Format("{0} {1}", fullName.FirstName, fullName.LastName), d(createEntity()));
        }
        public void TestPermanentResidenceCountryCode_Notsupported()
        {
            var state       = "TN";
            var mailAddress = new AddressDTO();

            mailAddress.Country    = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME;
            mailAddress.Division   = state;
            mailAddress.Street1    = "street1";
            mailAddress.PostalCode = "11111";

            var usAddress = new AddressDTO();

            usAddress.Country    = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME;
            usAddress.Division   = state;
            usAddress.Street1    = "street2";
            usAddress.PostalCode = "22222";

            string   birthCity              = "birth city";
            string   birthCountryCode       = "US";
            var      birthCountryReasonCode = USBornReasonType.Item01.ToString();
            DateTime birthDate              = DateTime.Now;
            string   citizenshipCountryCode = "UK";
            string   emailAddress           = "*****@*****.**";

            var firstName = "first";
            var lastName  = "last";
            var passport  = "passport";
            var preferred = "preferred";
            var suffix    = "Jr.";
            var fullName  = new FullName(firstName, lastName, passport, preferred, suffix);

            string gender = Gender.SEVIS_FEMALE_GENDER_CODE_VALUE;
            string permanentResidenceCountryCode = "FR";
            string phoneNumber  = "18505551212";
            string relationship = DependentCodeType.Item01.ToString();
            var    isTravelingWithParticipant = true;
            var    isDeleted = false;
            Func <AddedDependent> createEntity = () =>
            {
                return(new AddedDependent(
                           fullName: fullName,
                           birthCity: birthCity,
                           birthCountryCode: birthCountryCode,
                           birthCountryReasonCode: birthCountryReasonCode,
                           birthDate: birthDate,
                           citizenshipCountryCode: citizenshipCountryCode,
                           emailAddress: emailAddress,
                           gender: gender,
                           permanentResidenceCountryCode: permanentResidenceCountryCode,
                           phoneNumber: phoneNumber,
                           relationship: relationship,
                           mailAddress: mailAddress,
                           usAddress: usAddress,
                           printForm: true,
                           isTravelingWithParticipant: isTravelingWithParticipant,
                           personId: 10,
                           participantId: 20,
                           isDeleted: isDeleted));
            };

            var instance  = createEntity();
            var validator = new DependentValidator();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            permanentResidenceCountryCode = "US";
            instance = createEntity();
            result   = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(
                String.Format(DependentValidator.PERMANENT_RESIDENCE_COUNTRY_NOT_SUPPORTED, permanentResidenceCountryCode, validator.GetPersonType(instance), validator.GetNameDelegate()(instance)),
                result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(DependentErrorPath));
        }