Exemple #1
0
        /// <summary>
        /// Gets the interests from the details array
        /// </summary>
        /// <returns>A <see cref="InterestCollection"/></returns>
        private static InterestCollection ParseInterests()
        {
            InterestCollection interestCollection = new InterestCollection();
            var interestStrings = _contactDetails.Where(s => s.StartsWith("INTEREST;"));

            foreach (string interestStr in interestStrings)
            {
                string interestString = interestStr.Replace("INTEREST;", "");
                interestString = interestString.Replace("LEVEL=", "");
                Interest interest = new Interest();
                if (interestString.StartsWith("HIGH") || interestString.StartsWith("high"))
                {
                    interest.Level    = Level.High;
                    interest.Activity = interestString.Replace("HIGH:", "").Replace("high:", "").Trim();
                    interestCollection.Add(interest);
                }
                else if (interestString.StartsWith("MEDIUM") || interestString.StartsWith("medium"))
                {
                    interest.Level    = Level.Medium;
                    interest.Activity = interestString.Replace("MEDIUM:", "").Replace("medium:", "").Trim();
                    interestCollection.Add(interest);
                }
                else if (interestString.StartsWith("LOW") || interestString.StartsWith("low"))
                {
                    interest.Level    = Level.Low;
                    interest.Activity = interestString.Replace("LOW:", "").Replace("low:", "").Trim();
                    interestCollection.Add(interest);
                }
            }
            return(interestCollection);
        }
 public void InsertAndRemove()
 {
     Assert.DoesNotThrow(delegate
     {
         Interest interest = new Interest();
         InterestCollection interestCollection = new InterestCollection();
         interestCollection.Add(interest);
         interest = interestCollection[0];
         interestCollection[0] = interest;
         interestCollection.Remove(interest);
     });
 }
 public ConstituentInfo(DataSet tessResults)
 {
     DataTableCollection tables = tessResults.Tables;
     if (tables.Contains("Addresses") && tables["Addresses"].Rows.Count > 0)
     {
         Addresses = new AddressCollection(tables["Addresses"]);
     }
     if (tables.Contains("ConstituentAttribute")
             && tables["ConstituentAttribute"].Rows.Count > 0)
     {
         Attributes = new ConstituentAttributeCollection(tables["ConstituentAttribute"]);
     }
     if (tables.Contains("EmailAddresses") && tables["EmailAddresses"].Rows.Count > 0)
     {
         EmailAddresses = new EmailAddressCollection(tables["EmailAddresses"]);
     }
     if (tables.Contains("Associations") && tables["Associations"].Rows.Count > 0)
     {
         Associations = new AssociationCollection(tables["Associations"]);
     }
     if (tables.Contains("Constituency") && tables["Constituency"].Rows.Count > 0)
     {
         Constituencies = new ConstituencyCollection(tables["Constituency"]);
     }
     if (tables.Contains("ConstituentHeader") && tables["ConstituentHeader"].Rows.Count > 0)
     {
         Header = new ConstituentHeader(tables["ConstituentHeader"]);
     }
     if (tables.Contains("Contribution") && tables["Contribution"].Rows.Count > 0)
     {
         Contributions = new ContributionRecordCollection(tables["Contribution"]);
     }
     if (tables.Contains("Interests") && tables["Interests"].Rows.Count > 0)
     {
         Interests = new InterestCollection(tables["Interests"]);
     }
     if (tables.Contains("Memberships") && tables["Memberships"].Rows.Count > 0)
     {
         Memberships = new MembershipCollection(tables["Memberships"]);
     }
     if (tables.Contains("Phones") && tables["Phones"].Rows.Count > 0)
     {
         PhoneNumbers = new PhoneNumberCollection(tables["Phones"]);
     }
     if (tables.Contains("ProgramListings") && tables["ProgramListings"].Rows.Count > 0)
     {
         ProgramListings = new ProgramListingCollection(tables["ProgramListings"]);
     }
     if (tables.Contains("Rankings") && tables["Rankings"].Rows.Count > 0)
     {
         Rankings = new RankCollection(tables["Rankings"]);
     }
 }
        public void InsertAndRemoveNonExistentIndices()
        {
            InterestCollection interestCollection = new InterestCollection();

            Assert.Throws <IndexOutOfRangeException>(delegate
            {
                var interest_ = interestCollection[0];
            });
            var interest = new Interest();

            Assert.Throws <IndexOutOfRangeException>(delegate
            {
                interestCollection[0] = interest;
            });
        }