diff --git a/MimeKit/Cryptography/SecureMailboxAddress.cs b/MimeKit/Cryptography/SecureMailboxAddress.cs index c71a6af95f..952ab12c27 100644 --- a/MimeKit/Cryptography/SecureMailboxAddress.cs +++ b/MimeKit/Cryptography/SecureMailboxAddress.cs @@ -91,7 +91,30 @@ public SecureMailboxAddress (Encoding encoding, string name, IEnumerable /// -or- /// is null. /// - public SecureMailboxAddress (string name, IEnumerable route, string address, string fingerprint) : base (Encoding.UTF8, name, route, address) + public SecureMailboxAddress (string name, IEnumerable route, string address, string fingerprint) : base (name, route, address) + { + ValidateFingerprint (fingerprint); + + Fingerprint = fingerprint; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Creates a new with the specified fingerprint. + /// + /// The route of the mailbox. + /// The address of the mailbox. + /// The fingerprint of the certificate belonging to the owner of the mailbox. + /// + /// is null. + /// -or- + /// is null. + /// -or- + /// is null. + /// + public SecureMailboxAddress (IEnumerable route, string address, string fingerprint) : base (route, address) { ValidateFingerprint (fingerprint); @@ -136,7 +159,27 @@ public SecureMailboxAddress (Encoding encoding, string name, string address, str /// -or- /// is null. /// - public SecureMailboxAddress (string name, string address, string fingerprint) : base (Encoding.UTF8, name, address) + public SecureMailboxAddress (string name, string address, string fingerprint) : base (name, address) + { + ValidateFingerprint (fingerprint); + + Fingerprint = fingerprint; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Creates a new with the specified fingerprint. + /// + /// The address of the mailbox. + /// The fingerprint of the certificate belonging to the owner of the mailbox. + /// + /// is null. + /// -or- + /// is null. + /// + public SecureMailboxAddress (string address, string fingerprint) : base (address) { ValidateFingerprint (fingerprint); diff --git a/MimeKit/MailboxAddress.cs b/MimeKit/MailboxAddress.cs index 7ba285bb43..2f6585e2af 100644 --- a/MimeKit/MailboxAddress.cs +++ b/MimeKit/MailboxAddress.cs @@ -96,6 +96,23 @@ public MailboxAddress (string name, IEnumerable route, string address) : { } + /// + /// Initializes a new instance of the class. + /// + /// + /// Creates a new with the specified address and route. + /// + /// The route of the mailbox. + /// The address of the mailbox. + /// + /// is null. + /// -or- + /// is null. + /// + public MailboxAddress (IEnumerable route, string address) : this (Encoding.UTF8, null, route, address) + { + } + /// /// Initializes a new instance of the class. /// @@ -137,6 +154,20 @@ public MailboxAddress (string name, string address) : this (Encoding.UTF8, name, { } + /// + /// Initializes a new instance of the class. + /// + /// + /// Creates a new with the specified address. + /// + /// The address of the mailbox. + /// + /// is null. + /// + public MailboxAddress (string address) : this (Encoding.UTF8, null, address) + { + } + /// /// Clone the mailbox address. /// diff --git a/UnitTests/MailboxAddressTests.cs b/UnitTests/MailboxAddressTests.cs index 82dba20a51..8e09ab9c96 100644 --- a/UnitTests/MailboxAddressTests.cs +++ b/UnitTests/MailboxAddressTests.cs @@ -26,6 +26,7 @@ using System; using System.Text; +using System.Collections.Generic; using NUnit.Framework; @@ -48,11 +49,16 @@ public void ArgumentExceptionTests () Assert.Throws (() => new MailboxAddress ("name", null, "example.com")); Assert.Throws (() => new MailboxAddress ("name", route, null)); + Assert.Throws (() => new MailboxAddress ((IEnumerable) null, "example.com")); + Assert.Throws (() => new MailboxAddress (route, null)); + Assert.Throws (() => new MailboxAddress (null, "name", "example.com")); Assert.Throws (() => new MailboxAddress (Encoding.UTF8, "name", null)); Assert.Throws (() => new MailboxAddress ("name", null)); + Assert.Throws (() => new MailboxAddress (null)); + Assert.Throws (() => mailbox.Encoding = null); Assert.Throws (() => mailbox.CompareTo (null));