public void Constructor_NullUrl()
        {
            vCardWebsite site = new vCardWebsite((string)null);

            Assert.IsEmpty(
                site.Url,
                "The Url should be String.Empty even when initialized to null.");

        }
        public void Constructor_Url_WebSiteType()
        {

            vCardWebsite site = new vCardWebsite(
                TestUrl, vCardWebsiteTypes.Personal);

            Assert.AreEqual(
                TestUrl,
                site.Url,
                "The URL was not assigned properly by the constructor.");

            Assert.AreEqual(
                vCardWebsiteTypes.Personal,
                site.WebsiteType,
                "The site type should have been set.");

        }
        public void Constructor()
        {

            // Tests for default values when a web site
            // object is created without parameters.

            vCardWebsite site = new vCardWebsite();

            Assert.AreEqual(
                site.WebsiteType,
                vCardWebsiteTypes.Default,
                "The site type should be the default.");

            Assert.IsEmpty(
                site.Url,
                "The Url should be String.Empty because it was not initialized.");

        }
        public void Constructor_Url()
        {

            // Tests for values when a web site is created
            // with a URL.

            vCardWebsite site = new vCardWebsite(TestUrl);

            Assert.AreEqual(
                TestUrl,
                site.Url,
                "The URL was not assigned properly by the constructor.");

            Assert.AreEqual(
                vCardWebsiteTypes.Default,
                site.WebsiteType,
                "The site type should be default because it was not specified.");

        }
示例#5
0
        /// <summary>
        ///     Asserts that two web sites are identical.
        /// </summary>
        public static void Equals(vCardWebsite w1, vCardWebsite w2)
        {

            Assert.AreEqual(
                w1.IsPersonalSite,
                w2.IsPersonalSite,
                "vCardWebSite.IsPersonalSite differs.");

            Assert.AreEqual(
                w1.IsWorkSite,
                w2.IsWorkSite,
                "vCardWebSite.IsWorkSite differs.");

            Assert.AreEqual(
                w1.ToString(),
                w2.ToString(),
                "vCardWebSite.ToString() differs.");

            Assert.AreEqual(
                w1.Url,
                w2.Url,
                "vCardWebSite.Url differs.");

            Assert.AreEqual(
                w1.WebsiteType,
                w2.WebsiteType,
                "vCardWebSite.WebSiteType differs.");

        }
        public void ReadWriteProperty_Url()
        {

            vCardWebsite site = new vCardWebsite();

            site.Url = TestUrl;
            Assert.AreEqual(
                TestUrl,
                site.Url,
                "The Url property is not working.");

        }
        public void ReadWriteProperty_WebSiteType()
        {

            vCardWebsite site = new vCardWebsite();

            site.WebsiteType = vCardWebsiteTypes.Personal;
            
            Assert.AreEqual(
                vCardWebsiteTypes.Personal,
                site.WebsiteType,
                "The web site type should be set to Personal.");

            Assert.IsTrue(
                site.IsPersonalSite,
                "The IsPersonalSite property should be true.");

            Assert.IsFalse(
                site.IsWorkSite,
                "The IsWorkSite property should be false.");

            site.WebsiteType = vCardWebsiteTypes.Work;

            Assert.AreEqual(
                vCardWebsiteTypes.Work,
                site.WebsiteType,
                "The web site type should be set to Work.");

            Assert.IsFalse(
                site.IsPersonalSite,
                "The IsPersonalSite property should be false.");

            Assert.IsTrue(
                site.IsWorkSite,
                "The IsWorkSite property should be true.");

            // Now set both types.

            site.WebsiteType = vCardWebsiteTypes.Personal | vCardWebsiteTypes.Work;

            Assert.IsTrue(
                site.IsPersonalSite,
                "The IsPersonalSite property should also be true.");

            Assert.IsTrue(
                site.IsWorkSite,
                "The IsWorkSite property should also be true.");

            Assert.AreEqual(
                vCardWebsiteTypes.Personal | vCardWebsiteTypes.Work,
                site.WebsiteType,
                "The WebSiteType property is not working for multiple values.");

        }
        public void ReadWriteProperty_IsWorkSite()
        {

            vCardWebsite site = new vCardWebsite();

            site.IsWorkSite = true;
            Assert.IsTrue(
                site.IsWorkSite,
                "The IsWorkSite property should be true.");

            site.IsWorkSite = false;
            Assert.IsFalse(
                site.IsWorkSite,
                "The IsWorkSite property should be false.");

        }
示例#9
0
        /// <summary>
        ///     Reads the URL property.
        /// </summary>
        private void ReadInto_URL(vCard card, vCardProperty property)
        {

            vCardWebsite webSite = new vCardWebsite();

            webSite.Url = property.ToString();

            if (property.Subproperties.Contains("HOME"))
                webSite.IsPersonalSite = true;

            if (property.Subproperties.Contains("WORK"))
                webSite.IsWorkSite = true;

            card.Websites.Add(webSite);

        }
示例#10
0
 /// <summary>
 /// Utility method to convert website information from the vCard library to a
 /// WinRT ContactWebsite instance.
 /// No 1:1 matching is possible between both classes, the method tries to
 /// keep the conversion as accurate as possible.
 /// </summary>
 /// <param name="website">Website information from the vCard library.</param>
 /// <returns>The website information from the vCard library converted to a 
 /// WinRT ContactWebsite instance.</returns>
 private ContactWebsite ConvertVcardToWebsite(vCardWebsite website)
 {
     return new ContactWebsite
     {
         Uri = new Uri(website.Url)
     };
 }