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)); }
public void TestShouldValidate_ShouldNotValidate() { 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; var printForm = true; var sevisId = "sevisId"; var remarks = "remarks"; var personId = 1; var participantId = 2; Func <UpdatedDependent> createEntity = () => { return(new UpdatedDependent( fullName, birthCity, birthCountryCode, birthCountryReasonCode, birthDate, citizenshipCountryCode, emailAddress, gender, permanentResidenceCountryCode, phoneNumber, relationship, mailAddress, usAddress, printForm, sevisId, remarks, personId, participantId, isTravelingWithParticipant, 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); isDeleted = true; permanentResidenceCountryCode = "US"; instance = createEntity(); result = validator.Validate(instance); Assert.IsTrue(result.IsValid); Assert.AreEqual(0, result.Errors.Count); }
public void TestBirthDate_Spouse_IsMoreThanMaxYearsOld() { 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); birthDate = birthDate.AddYears(-2 * DependentValidator.MAX_DEPENDENT_AGE); instance = createEntity(); result = validator.Validate(instance); Assert.IsTrue(result.IsValid); Assert.IsTrue(instance.IsSpousalDependent()); }