Skip to content

Commit

Permalink
Added new MailboxAddress constructors that do not take a 'name' argument
Browse files Browse the repository at this point in the history
Issue #267
  • Loading branch information
jstedfast committed Oct 2, 2016
1 parent b5f963d commit 35d9008
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
47 changes: 45 additions & 2 deletions MimeKit/Cryptography/SecureMailboxAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,30 @@ public SecureMailboxAddress (Encoding encoding, string name, IEnumerable<string>
/// <para>-or-</para>
/// <para><paramref name="fingerprint"/> is <c>null</c>.</para>
/// </exception>
public SecureMailboxAddress (string name, IEnumerable<string> route, string address, string fingerprint) : base (Encoding.UTF8, name, route, address)
public SecureMailboxAddress (string name, IEnumerable<string> route, string address, string fingerprint) : base (name, route, address)
{
ValidateFingerprint (fingerprint);

Fingerprint = fingerprint;
}

/// <summary>
/// Initializes a new instance of the <see cref="SecureMailboxAddress"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="SecureMailboxAddress"/> with the specified fingerprint.
/// </remarks>
/// <param name="route">The route of the mailbox.</param>
/// <param name="address">The address of the mailbox.</param>
/// <param name="fingerprint">The fingerprint of the certificate belonging to the owner of the mailbox.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="route"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="address"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="fingerprint"/> is <c>null</c>.</para>
/// </exception>
public SecureMailboxAddress (IEnumerable<string> route, string address, string fingerprint) : base (route, address)
{
ValidateFingerprint (fingerprint);

Expand Down Expand Up @@ -136,7 +159,27 @@ public SecureMailboxAddress (Encoding encoding, string name, string address, str
/// <para>-or-</para>
/// <para><paramref name="fingerprint"/> is <c>null</c>.</para>
/// </exception>
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;
}

/// <summary>
/// Initializes a new instance of the <see cref="SecureMailboxAddress"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="SecureMailboxAddress"/> with the specified fingerprint.
/// </remarks>
/// <param name="address">The address of the mailbox.</param>
/// <param name="fingerprint">The fingerprint of the certificate belonging to the owner of the mailbox.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="address"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="fingerprint"/> is <c>null</c>.</para>
/// </exception>
public SecureMailboxAddress (string address, string fingerprint) : base (address)
{
ValidateFingerprint (fingerprint);

Expand Down
31 changes: 31 additions & 0 deletions MimeKit/MailboxAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ public MailboxAddress (string name, IEnumerable<string> route, string address) :
{
}

/// <summary>
/// Initializes a new instance of the <see cref="MimeKit.MailboxAddress"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailboxAddress"/> with the specified address and route.
/// </remarks>
/// <param name="route">The route of the mailbox.</param>
/// <param name="address">The address of the mailbox.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="route"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="address"/> is <c>null</c>.</para>
/// </exception>
public MailboxAddress (IEnumerable<string> route, string address) : this (Encoding.UTF8, null, route, address)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="MimeKit.MailboxAddress"/> class.
/// </summary>
Expand Down Expand Up @@ -137,6 +154,20 @@ public MailboxAddress (string name, string address) : this (Encoding.UTF8, name,
{
}

/// <summary>
/// Initializes a new instance of the <see cref="MimeKit.MailboxAddress"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailboxAddress"/> with the specified address.
/// </remarks>
/// <param name="address">The address of the mailbox.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="address"/> is <c>null</c>.
/// </exception>
public MailboxAddress (string address) : this (Encoding.UTF8, null, address)
{
}

/// <summary>
/// Clone the mailbox address.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions UnitTests/MailboxAddressTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

using System;
using System.Text;
using System.Collections.Generic;

using NUnit.Framework;

Expand All @@ -48,11 +49,16 @@ public void ArgumentExceptionTests ()
Assert.Throws<ArgumentNullException> (() => new MailboxAddress ("name", null, "example.com"));
Assert.Throws<ArgumentNullException> (() => new MailboxAddress ("name", route, null));

Assert.Throws<ArgumentNullException> (() => new MailboxAddress ((IEnumerable<string>) null, "example.com"));
Assert.Throws<ArgumentNullException> (() => new MailboxAddress (route, null));

Assert.Throws<ArgumentNullException> (() => new MailboxAddress (null, "name", "example.com"));
Assert.Throws<ArgumentNullException> (() => new MailboxAddress (Encoding.UTF8, "name", null));

Assert.Throws<ArgumentNullException> (() => new MailboxAddress ("name", null));

Assert.Throws<ArgumentNullException> (() => new MailboxAddress (null));

Assert.Throws<ArgumentNullException> (() => mailbox.Encoding = null);

Assert.Throws<ArgumentNullException> (() => mailbox.CompareTo (null));
Expand Down

0 comments on commit 35d9008

Please sign in to comment.