/// <summary>
        /// Returns all update sevis batch objects.  For example, if a participant has been sent to sevis and
        /// a name has changed, a dependent has been added, and another dependent has been updated.  This collection
        /// will contain all update sevis exchange visitor objects to perform those updates.
        /// </summary>
        /// <param name="sevisUsername">The sevis username the exchange visitor is being sent with.</param>
        /// <param name="previouslySubmittedExchangeVisitor">The previously submitted exchange visitor model to sevis.</param>
        /// <returns>All update sevis batch objects.</returns>
        public IEnumerable <SEVISEVBatchTypeExchangeVisitor1> GetSEVISEVBatchTypeExchangeVisitor1Collection(string sevisUsername, ExchangeVisitor previouslySubmittedExchangeVisitor)
        {
            Contract.Requires(sevisUsername != null, "The sevis username must not be null.");
            var visitors = new List <SEVISEVBatchTypeExchangeVisitor1>();
            Func <object, RequestId, SEVISEVBatchTypeExchangeVisitor1> createUpdateExchangeVisitor = (item, requestId) =>
            {
                return(new SEVISEVBatchTypeExchangeVisitor1
                {
                    Item = item,
                    requestID = requestId.ToString(),
                    sevisID = this.SevisId,
                    statusCodeSpecified = false,
                    userID = sevisUsername
                });
            };
            var personChangeDetail          = this.Person.GetChangeDetail(previouslySubmittedExchangeVisitor.Person);
            var fullNameChangeDetail        = this.Person.FullName.GetChangeDetail(previouslySubmittedExchangeVisitor.Person.FullName);
            var subjectFieldChangeDetail    = this.Person.SubjectField.GetChangeDetail(previouslySubmittedExchangeVisitor.Person.SubjectField);
            var financialInfoChangeDetail   = this.FinancialInfo.GetChangeDetail(previouslySubmittedExchangeVisitor.FinancialInfo);
            var exchangeVisitorChangeDetail = this.GetChangeDetail(previouslySubmittedExchangeVisitor);

            if (personChangeDetail.HasChanges() || fullNameChangeDetail.HasChanges())
            {
                visitors.Add(createUpdateExchangeVisitor(this.Person.GetSEVISEVBatchTypeExchangeVisitorBiographical(), new RequestId(this.Person.ParticipantId, RequestIdType.Participant, RequestActionType.Update)));
            }
            if (subjectFieldChangeDetail.HasChanges())
            {
                var exchangeVisitorProgram = new SEVISEVBatchTypeExchangeVisitorProgram();
                exchangeVisitorProgram.Item = this.Person.SubjectField.GetSEVISEVBatchTypeExchangeVisitorProgramEditSubject();
                visitors.Add(createUpdateExchangeVisitor(exchangeVisitorProgram, new RequestId(this.Person.ParticipantId, RequestIdType.SubjectField, RequestActionType.Update)));
            }
            if (financialInfoChangeDetail.HasChanges())
            {
                visitors.Add(createUpdateExchangeVisitor(this.FinancialInfo.GetSEVISEVBatchTypeExchangeVisitorFinancialInfo(), new RequestId(this.Person.ParticipantId, RequestIdType.FinancialInfo, RequestActionType.Update)));
            }
            foreach (var dependent in this.Dependents)
            {
                var previousDependent = previouslySubmittedExchangeVisitor.Dependents.Where(x => x.PersonId == dependent.PersonId).FirstOrDefault();
                if (previousDependent == null)
                {
                    var modifiedDependent = new ModifiedParticipantDependent(dependent);
                    visitors.Add(createUpdateExchangeVisitor(modifiedDependent.GetSEVISEVBatchTypeExchangeVisitorDependent(), dependent.GetRequestId()));
                }
                else
                {
                    var changeDetail = dependent.GetChangeDetail(previousDependent);
                    if (changeDetail.HasChanges())
                    {
                        var modifiedDependent = new ModifiedParticipantDependent(dependent);
                        visitors.Add(createUpdateExchangeVisitor(modifiedDependent.GetSEVISEVBatchTypeExchangeVisitorDependent(), dependent.GetRequestId()));
                    }
                }
            }
            return(visitors);
        }
        public void TestGetSEVISEVBatchTypeExchangeVisitorDependent()
        {
            var personId      = 100;
            var participantId = 200;

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

            var birthCity              = "birth city";
            var birthCountryCode       = "CN";
            var birthDate              = DateTime.UtcNow;
            var citizenshipCountryCode = "FR";
            var email  = "*****@*****.**";
            var gender = Gender.SEVIS_MALE_GENDER_CODE_VALUE;
            var permanentResidenceCountryCode = "MX";
            var phone       = "123-456-7890";
            var mailAddress = new AddressDTO
            {
                AddressId = 1,
                Country   = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME
            };
            var usAddress = new AddressDTO
            {
                AddressId = 2,
                Country   = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME
            };
            var printForm = true;
            var birthCountryReasonCode     = USBornReasonType.Item01.ToString();
            var relationship               = DependentCodeType.Item01.ToString();
            var isTravelingWithParticipant = true;
            var isDeleted = false;

            var dependent = new AddedDependent(
                fullName: fullName,
                birthCity: birthCity,
                birthCountryCode: birthCountryCode,
                birthCountryReasonCode: birthCountryReasonCode,
                birthDate: birthDate,
                citizenshipCountryCode: citizenshipCountryCode,
                emailAddress: email,
                gender: gender,
                permanentResidenceCountryCode: permanentResidenceCountryCode,
                phoneNumber: phone,
                relationship: relationship,
                mailAddress: mailAddress,
                usAddress: usAddress,
                printForm: printForm,
                participantId: participantId,
                personId: personId,
                isTravelingWithParticipant: isTravelingWithParticipant,
                isDeleted: isDeleted
                );

            var modifiedParticipantDependent = new ModifiedParticipantDependent(dependent: dependent);

            var instance = modifiedParticipantDependent.GetSEVISEVBatchTypeExchangeVisitorDependent();

            Assert.IsNotNull(instance.Item);
            Assert.IsInstanceOfType(instance.Item, typeof(SEVISEVBatchTypeExchangeVisitorDependentAdd));
            Assert.IsNotNull(instance.UserDefinedA);
            Assert.IsNotNull(instance.UserDefinedB);

            var key = new ParticipantSevisKey(instance.UserDefinedA, instance.UserDefinedB);

            Assert.AreEqual(participantId, key.ParticipantId);
            Assert.AreEqual(personId, key.PersonId);
        }
        public void TestConstructor()
        {
            var personId      = 100;
            var participantId = 200;

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

            var birthCity              = "birth city";
            var birthCountryCode       = "CN";
            var birthDate              = DateTime.UtcNow;
            var citizenshipCountryCode = "FR";
            var email  = "*****@*****.**";
            var gender = Gender.SEVIS_MALE_GENDER_CODE_VALUE;
            var permanentResidenceCountryCode = "MX";
            var phone       = "123-456-7890";
            var mailAddress = new AddressDTO
            {
                AddressId = 1,
                Country   = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME
            };
            var usAddress = new AddressDTO
            {
                AddressId = 2,
                Country   = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME
            };
            var printForm = true;
            var birthCountryReasonCode     = USBornReasonType.Item01.ToString();
            var relationship               = DependentCodeType.Item01.ToString();
            var isTravelingWithParticipant = true;
            var isDeleted = false;

            var dependent = new AddedDependent(
                fullName: fullName,
                birthCity: birthCity,
                birthCountryCode: birthCountryCode,
                birthCountryReasonCode: birthCountryReasonCode,
                birthDate: birthDate,
                citizenshipCountryCode: citizenshipCountryCode,
                emailAddress: email,
                gender: gender,
                permanentResidenceCountryCode: permanentResidenceCountryCode,
                phoneNumber: phone,
                relationship: relationship,
                mailAddress: mailAddress,
                usAddress: usAddress,
                printForm: printForm,
                participantId: participantId,
                personId: personId,
                isTravelingWithParticipant: isTravelingWithParticipant,
                isDeleted: isDeleted
                );

            var modifiedParticipantDependent = new ModifiedParticipantDependent(dependent);

            Assert.IsTrue(Object.ReferenceEquals(dependent, modifiedParticipantDependent.Dependent));
        }