Esempio n. 1
0
        /// <summary>
        ///     Looks for the first phone of the specified
        ///     type that is a preferred phone.
        /// </summary>
        /// <param name="phoneType">
        ///     The type of phone to seek.
        /// </param>
        /// <returns>
        ///     The first <see cref="vCardPhone "/> that matches
        ///     the specified type.  A preferred number is returned
        ///     before a non-preferred number.
        /// </returns>
        public vCardPhone GetFirstChoice(vCardPhoneTypes phoneType)
        {
            vCardPhone firstNonPreferred = null;

            foreach (vCardPhone phone in this)
            {
                if ((phone.PhoneType & phoneType) == phoneType)
                {
                    // This phone has the same phone type as
                    // specified by the caller.  Save a reference
                    // to the first such phone encountered.

                    if (firstNonPreferred == null)
                    {
                        firstNonPreferred = phone;
                    }

                    if (phone.IsPreferred)
                    {
                        return(phone);
                    }
                }
            }

            // No phone had the specified phone type and was marked
            // as preferred.

            return(firstNonPreferred);
        }
Esempio n. 2
0
        private void CheckPhone(vCardPhoneCollection phones, string value, vCardPhoneTypes types, bool isPreferred)
        {
            if (phones == null || phones.Count == 0)
            {
                Assert.Fail("phones null or empty");
            }

            var p = phones.FirstOrDefault(x => x.FullNumber == value);

            if (p == null)
            {
                Assert.Fail("phone number not found for value " + value);
            }

            Assert.AreEqual(types, p.PhoneType);

            Assert.AreEqual(isPreferred, p.IsPreferred);


            //  types.HasFlag(
        }
Esempio n. 3
0
        public static TelephoneType ConvertPhoneType(vCardPhoneTypes type)
        {
            switch (type)
            {
            case vCardPhoneTypes.BBS:
                return(TelephoneType.Bbs);

            case vCardPhoneTypes.Car:
                return(TelephoneType.Car);

            case vCardPhoneTypes.Cellular:
            case vCardPhoneTypes.CellularVoice:
                return(TelephoneType.Cell);

            case vCardPhoneTypes.Fax:
                return(TelephoneType.Fax);

            case vCardPhoneTypes.Home:
                return(TelephoneType.Home);

            case vCardPhoneTypes.ISDN:
                return(TelephoneType.Isdn);

            case vCardPhoneTypes.Work:
            case vCardPhoneTypes.WorkVoice:
                return(TelephoneType.Work);

            case vCardPhoneTypes.WorkFax:
                return(TelephoneType.Fax);

            case vCardPhoneTypes.Voice:
                return(TelephoneType.Voice);

            default:
                return(TelephoneType.Work);
            }
        }
Esempio n. 4
0
 /// <summary>
 ///     Creates a new <see cref="vCardPhone"/> with the specified number and subtype.
 /// </summary>
 /// <param name="fullNumber">The phone number.</param>
 /// <param name="phoneType">The phone subtype.</param>
 public vCardPhone(string fullNumber, vCardPhoneTypes phoneType)
 {
     this.fullNumber = fullNumber;
     this.phoneType  = phoneType;
 }
Esempio n. 5
0
 /// <summary>
 ///     Creates a new <see cref="vCardPhone"/> with the specified number and subtype.
 /// </summary>
 /// <param name="fullNumber">The phone number.</param>
 /// <param name="phoneType">The phone subtype.</param>
 public vCardPhone(string fullNumber, vCardPhoneTypes phoneType)
 {
     this.fullNumber = fullNumber;
     this.phoneType = phoneType;
 }
            }

            var sp = sps.FirstOrDefault(x => x.Username == username && x.ServiceType == serviceType);

            Assert.IsNotNull(sp, "no match for socialProfile for " + username + " for serviceType " + serviceType.ToString());


            Assert.AreEqual(url, sp.ProfileUrl);
            Assert.AreEqual(username, sp.Username);
            Assert.AreEqual(serviceType, sp.ServiceType);

        }

        private void CheckIM(vCardIMPPCollection ims, string handle, IMServiceType serviceType, ItemType itemType, bool isPreferred)
        {

            if (ims == null || ims.Count == 0)
            {
                Assert.Fail("ims null or empty");
            }

            var im = ims.FirstOrDefault(x => x.Handle == handle && x.ServiceType == serviceType);

            Assert.IsNotNull(im, "im not matched for handle " + handle + " and servicetype " + serviceType.ToString());
            Assert.AreEqual(itemType,im.ItemType);