public void CanAddExtendedUriProperty() { vCard v = new vCard(); v.AddExtendedProperty("where", "http://here.net", new vCardUriProperty("ldap://somefellow")); vCardUriProperty p = v.GetExtendedProperty("where", "http://here.net") as vCardUriProperty; Assert.IsNotNull(p); Assert.AreEqual("ldap://somefellow", p.ToString()); Assert.AreEqual("ldap://somefellow", p.Uri); }
public void CanAddExtendedTextProperty() { vCard v = new vCard(); v.AddExtendedProperty("why", "http://because.net", new vCardTextProperty("It is red")); vCardTextProperty p = v.GetExtendedProperty("why", "http://because.net") as vCardTextProperty; Assert.IsNotNull(p); Assert.AreEqual("It is red", p.ToString()); Assert.AreEqual("It is red", p.Text); }
public void CanReadXmlvCard() { string xml = @"<?xml version=""1.0"" encoding=""utf-8""?> <vcards xmlns=""urn:ietf:params:xml:ns:vcard-4.0""> <vcard> <fn> <text>John Doe</text> </fn> <n> <surname><text>Doe</text></surname> <given><text>J.</text></given> </n> <email><text>[email protected]</text></email> <name><text>JohnDoe</text></name> <source><uri>http://www.somewhere.com</uri></source> <ex:why xmlns:ex=""http://here.net"">It is red</ex:why> <ex:where xmlns:ex=""http://here.net""> <uri>ldap://somefellow</uri> </ex:where> </vcard> </vcards>"; using (StringReader r = new StringReader(xml)) { vCardXmlReader reader = new vCardXmlReader(); vCard c = reader.Read(r, ParseExtensions); Assert.IsNotNull(c); Assert.AreEqual("John Doe", c.Fn.Default.Value); Assert.AreEqual("*****@*****.**", c.EMail.Default.Value); Assert.AreEqual("JohnDoe", c.Name); Assert.AreEqual("Doe", c.N.FamilyName); Assert.AreEqual("J.", c.N.GivenNames); Assert.AreEqual("http://www.somewhere.com", c.Source.Default.Value); vCardProperty p = c.GetExtendedProperty("why", "http://here.net"); Assert.IsNotNull(p); Assert.AreEqual("It is red", p.ToString()); } }