public void ReadWriteProperty_IsCar()
        {

            vCardPhone phone = new vCardPhone();

            phone.IsCar = true;
            Assert.IsTrue(phone.IsCar, "IsCar should have been set to true.");

            phone.IsCar = false;
            Assert.IsFalse(phone.IsCar, "IsCar should have been set to false.");

        }
        public void ReadWriteProperty_FullNumber()
        {

            // Make sure .FullNumber reads/writes

            vCardPhone phone = new vCardPhone();
            phone.FullNumber = "800-929-5805";
            Assert.AreEqual(
                "800-929-5805",
                phone.FullNumber,
                "The FullNumber property is not working.");

        }
        public void EmptyString_FullNumber()
        {

            vCardPhone phone = new vCardPhone();

            Assert.IsEmpty(
                phone.FullNumber,
                "The full number should default to String.Empty.");

            phone.FullNumber = null;

            Assert.IsEmpty(
                phone.FullNumber,
                "The FullNumber property should return String.Empty instead of null.");

        }
Example #4
0
        /// <summary>
        ///     Asserts that two vCard phones are identical.
        /// </summary>
        public static void Equals(vCardPhone p1, vCardPhone p2)
        {

            Assert.AreEqual(
                p1.FullNumber,
                p2.FullNumber,
                "vCardPhone.FullNumber differs.");

            Assert.AreEqual(
                p1.IsBBS,
                p2.IsBBS,
                "vCardPhone.IsBBS does not match.");

            Assert.AreEqual(
                p1.IsCar,
                p2.IsCar,
                "vCardPhone.IsCar does not match.");

            Assert.AreEqual(
                p1.IsCellular,
                p2.IsCellular,
                "vCardPhone.IsCellular does not match.");

            Assert.AreEqual(
                p1.IsFax,
                p2.IsFax,
                "vCardPhone.IsFax does not match.");

            Assert.AreEqual(
                p1.IsHome,
                p2.IsHome,
                "vCardPhone.IsHome does not match.");

            Assert.AreEqual(
                p1.IsISDN,
                p2.IsISDN,
                "vCardPhone.IsISDN does not match.");

            Assert.AreEqual(
                p1.IsMessagingService,
                p2.IsMessagingService,
                "vCardPhone.IsMessagingService does not match.");

            Assert.AreEqual(
                p1.IsModem,
                p2.IsModem,
                "vCardPhone.IsModem does not match.");

            Assert.AreEqual(
                p1.IsPager,
                p2.IsPager,
                "vCardPhone.IsPager does not match.");

            Assert.AreEqual(
                p1.IsPreferred,
                p2.IsPreferred,
                "vCardPhone.IsPreferred differs.");

            Assert.AreEqual(
                p1.IsVideo,
                p2.IsVideo,
                "vCardPhone.IsVideo does not match.");

            Assert.AreEqual(
                p1.IsVoice,
                p2.IsVoice,
                "vCardPhone.IsVoice does not match.");

            Assert.AreEqual(
                p1.IsWork,
                p2.IsWork,
                "vCardPhone.IsWork does not match.");

            Assert.AreEqual(
                p1.PhoneType,
                p2.PhoneType,
                "vCardPhone.PhoneType differs.");

            Assert.AreEqual(
                p1.ToString(),
                p2.ToString(),
                "vCardPhone.ToString differs.");

        }
        /// <summary>
        ///     Reads the TEL property.
        /// </summary>
        private void ReadInto_TEL(vCard card, vCardProperty property)
        {

            vCardPhone phone = new vCardPhone();

            // The full telephone number is stored as the 
            // value of the property.  Currently no formatted
            // rules are applied since the vCard specification
            // is somewhat confusing on this matter.

            phone.FullNumber = property.ToString();
            if (string.IsNullOrEmpty(phone.FullNumber))
                return;

            foreach (vCardSubproperty sub in property.Subproperties)
            {

                // If this subproperty is a TYPE subproperty
                // and it has a value, then it is expected
                // to contain a comma-delimited list of phone types.

                if (
                    (string.Compare(sub.Name, "TYPE", StringComparison.OrdinalIgnoreCase) == 0) &&
                    (!string.IsNullOrEmpty(sub.Value)))
                {
                    // This is a vCard 3.0 subproperty.  It defines the
                    // the list of phone types in a comma-delimited list.
                    // Note that the vCard specification allows for
                    // multiple TYPE subproperties (why ?!).

                    phone.PhoneType |=
                        ParsePhoneType(sub.Value.Split(new char[] { ',' }));

                }
                else
                {

                    // The other subproperties in a TEL property
                    // define the phone type.  The only exception
                    // are meta fields like ENCODING, CHARSET, etc,
                    // but these are probably rare with TEL.

                    phone.PhoneType |= ParsePhoneType(sub.Name);

                }

            }

            card.Phones.Add(phone);

        }
        public void ReadWriteProperty_IsPreferred()
        {

            vCardPhone phone = new vCardPhone();

            phone.IsPreferred = true;
            Assert.IsTrue(phone.IsPreferred, "IsPreferred should have been set to true.");

            phone.IsPreferred = false;
            Assert.IsFalse(phone.IsPreferred, "IsPreferred should have been set to false.");

        }
        public void ReadWriteProperty_IsMessagingService()
        {

            vCardPhone phone = new vCardPhone();

            phone.IsMessagingService = true;
            Assert.IsTrue(phone.IsMessagingService, "IsMessagingService should have been set to true.");

            phone.IsMessagingService = false;
            Assert.IsFalse(phone.IsMessagingService, "IsMessagingService should have been set to false.");

        }