예제 #1
0
        public void SamplevCardReadAndWriteTestWithEmailTypeFormat()
        {

            vCard card = new vCard();

            card.EmailAddresses.Add(new vCardEmailAddress() { Address = "*****@*****.**", EmailType = vCardEmailAddressType.Internet, IsPreferred = true, ItemType = ItemType.WORK });


            card.UniqueId = Guid.NewGuid().ToString("N");

            string text = card.ToString();

            vCardStandardWriter writer = new vCardStandardWriter();

            using (StringWriter sw = new StringWriter())
            {

                writer.Write(card, sw);

                sw.Flush();
                text = sw.ToString();
                sw.Close();
            }


            Assert.IsNotNull(text);


            vCardStandardReader reader = new vCardStandardReader();

            using (StringReader sr = new StringReader(text))
            {

                vCard cardFromReader = reader.Read(sr);

                Assert.AreEqual(1, cardFromReader.EmailAddresses.Count);

                var email = cardFromReader.EmailAddresses.First();
                Assert.AreEqual(true, email.IsPreferred);
                Assert.AreEqual(ItemType.WORK, email.ItemType);
                Assert.AreEqual(vCardEmailAddressType.Internet, email.EmailType);
                Assert.AreEqual("*****@*****.**", email.Address);
            }

        }
예제 #2
0
        // The following functions compare two vCard-related objects.
        
        #region [ Equals(vCard) ]

        public static void Equals(vCard c1, vCard c2)
        {

            // Start by comparing the base fields.

            Assert.AreEqual(
                c1.AdditionalNames,
                c2.AdditionalNames,
                "AdditionalNames does not match.");

            Assert.AreEqual(
                c1.BirthDate,
                c2.BirthDate,
                "BirthDate does not match.");

            Assert.AreEqual(
                c1.DisplayName,
                c2.DisplayName,
                "DisplayName does not match.");

            Assert.AreEqual(
                c1.FamilyName,
                c2.FamilyName,
                "FamilyName does not match.");

            Assert.AreEqual(
                c1.FormattedName,
                c2.FormattedName,
                "FormattedName does not match.");

            Assert.AreEqual(
                c1.Gender,
                c2.Gender,
                "Gender does not match.");

            Assert.AreEqual(
                c1.GivenName,
                c2.GivenName,
                "GivenName does not match.");

            Assert.AreEqual(
                c1.Mailer,
                c2.Mailer,
                "Mailer does not match.");

            Assert.AreEqual(
                c1.NamePrefix,
                c2.NamePrefix,
                "NamePrefix does not match.");

            Assert.AreEqual(
                c1.NameSuffix,
                c2.NameSuffix,
                "NameSuffix does not match.");

            Assert.AreEqual(
                c1.Organization,
                c2.Organization,
                "Organization does not match.");

            Assert.AreEqual(
                c1.ProductId,
                c2.ProductId,
                "ProductId does not match.");

            Assert.AreEqual(
                c1.RevisionDate,
                c2.RevisionDate,
                "RevisionDate does not match.");

            Assert.AreEqual(
                c1.Role,
                c2.Role,
                "Role does not match.");

            Assert.AreEqual(
                c1.TimeZone,
                c2.TimeZone,
                "TimeZone does not match.");

            Assert.AreEqual(
                c1.Title,
                c2.Title,
                "Title does not match.");

            Assert.AreEqual(
                c1.ToString(),
                c2.ToString(),
                "ToString() does not match.");

            Assert.AreEqual(
                c1.UniqueId,
                c2.UniqueId,
                "UniqueId does not match.");

            // Compare collections

            Equals(
                c1.Categories,
                c2.Categories);

            Equals(
                c1.DeliveryAddresses,
                c2.DeliveryAddresses);

            Equals(
                c1.DeliveryLabels,
                c2.DeliveryLabels);

            Equals(
                c1.EmailAddresses,
                c2.EmailAddresses);

            Equals(
                c1.Nicknames,
                c2.Nicknames);

            Equals(
                c1.Notes,
                c2.Notes);

            Equals(
                c1.Phones,
                c2.Phones);

            Equals(
                c1.Photos,
                c2.Photos);

            Equals(
                c1.Sources,
                c2.Sources);

            Equals(
                c1.Websites,
                c2.Websites);

        }