public void Constructor() { vCardEmailAddress email = new vCardEmailAddress(); Assert.IsEmpty( email.Address, "The Address property should default to String.Empty."); }
public void Constructor_String() { vCardEmailAddress email = new vCardEmailAddress(TestEmailAddress); Assert.AreEqual( TestEmailAddress, email.Address, "The EmailAddress is incorrect."); Assert.AreEqual( vCardEmailAddressType.Internet, email.EmailType, "The EmailType should default to Internet."); }
public void Constructor_String_EmailType() { // Create a non-Internet email address. Note: // currently address formats are not validated. // This means any type can be designated in the // constructor. However, this test may fail if // validation is implemented in the future. vCardEmailAddress email = new vCardEmailAddress( TestEmailAddress, vCardEmailAddressType.eWorld); Assert.AreEqual( TestEmailAddress, email.Address, "The EmailAddress is not correct."); Assert.AreEqual( vCardEmailAddressType.eWorld, email.EmailType, "The EmailType is not correct."); }
/// <summary> /// Asserts that two vCard email addresses are identical. /// </summary> public static void Equals(vCardEmailAddress e1, vCardEmailAddress e2) { Assert.AreEqual( e1.Address, e2.Address, "vCardEmailAddress.Address differs."); Assert.AreEqual( e1.EmailType, e2.EmailType, "vCardEmailAddress.EmailType differs."); Assert.AreEqual( e1.IsPreferred, e2.IsPreferred, "vCardEmailAddress.IsPreferred differs."); Assert.AreEqual( e1.ToString(), e2.ToString(), "vCardEmailAddress.ToString differs."); }
public void ReadWriteProperty_Address() { // Make sure the Address property reads/writes. vCardEmailAddress email = new vCardEmailAddress(); email.Address = TestEmailAddress; Assert.AreEqual( TestEmailAddress, email.Address, "The Address property is not working."); }
public void ReadWriteProperty_IsPreferred() { // Make sure the EmailType property reads/writes vCardEmailAddress email = new vCardEmailAddress(); email.IsPreferred = true; Assert.IsTrue(email.IsPreferred); email.IsPreferred = false; Assert.IsFalse(email.IsPreferred); }
public void ReadWriteProperty_EmailType() { // Make sure the EmailType property reads/writes vCardEmailAddress email = new vCardEmailAddress(); email.EmailType = vCardEmailAddressType.AttMail; Assert.AreEqual(vCardEmailAddressType.AttMail, email.EmailType); }
/// <summary> /// Reads an EMAIL property. /// </summary> private void ReadInto_EMAIL(vCard card, vCardProperty property) { vCardEmailAddress email = new vCardEmailAddress(); // The email address is stored as the value of the property. // The format of the address depends on the type of email // address. The current version of the library does not // perform any validation. email.Address = property.Value.ToString(); // Loop through each subproperty and look for flags // that indicate the type of email address. foreach (vCardSubproperty subproperty in property.Subproperties) { switch (subproperty.Name.ToUpperInvariant()) { case "PREF": // The PREF subproperty indicates the email // address is the preferred email address to // use when contacting the person. email.IsPreferred = true; break; case "TYPE": // The TYPE subproperty is new in vCard 3.0. // It identifies the type and can also indicate // the PREF attribute. string[] typeValues = subproperty.Value.Split(new char[] { ',' }); foreach (string typeValue in typeValues) { if (string.Compare("PREF", typeValue, true) == 0) { email.IsPreferred = true; } else { vCardEmailAddressType? typeType = DecodeEmailAddressType(typeValue); if (typeType.HasValue) email.EmailType = typeType.Value; } } break; default: // All other subproperties are probably vCard 2.1 // subproperties. This was before the email type // was supposed to be specified with TYPE=VALUE. vCardEmailAddressType? emailType = DecodeEmailAddressType(subproperty.Name); if (emailType.HasValue) email.EmailType = emailType.Value; break; } } card.EmailAddresses.Add(email); }