/// <summary> /// Initialize a new instance of the <see cref="EncoderFilter"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="IMimeFilter"/> using the specified encoder. /// </remarks> /// <param name="encoder">A specific encoder for the filter to use.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="encoder"/> is <c>null</c>. /// </exception> public EncoderFilter(IMimeEncoder encoder) { if (encoder == null) { throw new ArgumentNullException(nameof(encoder)); } Encoder = encoder; }
static void CloneAndAssert(IMimeEncoder encoder) { // first, set some random state SetRandomState(encoder); var clone = encoder.Clone(); AssertState(encoder, clone); AssertArgumentExceptions(encoder); }
static void ResetAndAssert(IMimeEncoder encoder) { // clone the encoder at it's initial state var clone = encoder.Clone(); // set some random state on the clone SetRandomState(clone); // reset the clone and make sure it matches clone.Reset(); AssertState(encoder, clone); }
static void AssertArgumentExceptions(IMimeEncoder encoder) { var output = new byte[0]; Assert.Throws <ArgumentNullException> (() => encoder.Encode(null, 0, 0, output)); Assert.Throws <ArgumentOutOfRangeException> (() => encoder.Encode(new byte[0], -1, 0, output)); Assert.Throws <ArgumentOutOfRangeException> (() => encoder.Encode(new byte[1], 0, 10, output)); Assert.Throws <ArgumentNullException> (() => encoder.Encode(new byte[1], 0, 1, null)); Assert.Throws <ArgumentException> (() => encoder.Encode(new byte[1], 0, 1, output)); Assert.Throws <ArgumentNullException> (() => encoder.Flush(null, 0, 0, output)); Assert.Throws <ArgumentOutOfRangeException> (() => encoder.Flush(new byte[0], -1, 0, output)); Assert.Throws <ArgumentOutOfRangeException> (() => encoder.Flush(new byte[1], 0, 10, output)); Assert.Throws <ArgumentNullException> (() => encoder.Flush(new byte[1], 0, 1, null)); Assert.Throws <ArgumentException> (() => encoder.Flush(new byte[1], 0, 1, output)); }
/// <summary> /// Initializes a new instance of the <see cref="MimeKit.IO.Filters.EncoderFilter"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="IMimeFilter"/> using the specified encoder. /// </remarks> /// <param name="encoder">A specific encoder for the filter to use.</param> public EncoderFilter(IMimeEncoder encoder) { Encoder = encoder; }
/// <summary> /// Initializes a new instance of the <see cref="MimeKit.IO.Filters.EncoderFilter"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="EncoderFilter"/> using the specified encoder. /// </remarks> /// <param name="encoder">A specific encoder for the filter to use.</param> public EncoderFilter (IMimeEncoder encoder) { Encoder = encoder; }
static void ResetAndAssert (IMimeEncoder encoder) { // clone the encoder at it's initial state var clone = encoder.Clone (); // set some random state on the clone SetRandomState (clone); // reset the clone and make sure it matches clone.Reset (); AssertState (encoder, clone); }
static void CloneAndAssert (IMimeEncoder encoder) { // first, set some random state SetRandomState (encoder); var clone = encoder.Clone (); Assert.AreEqual (encoder.Encoding, clone.Encoding); AssertState (encoder, clone); AssertArgumentExceptions (encoder); }
static void AssertArgumentExceptions (IMimeEncoder encoder) { var output = new byte[0]; Assert.Throws<ArgumentNullException> (() => encoder.Encode (null, 0, 0, output)); Assert.Throws<ArgumentOutOfRangeException> (() => encoder.Encode (new byte[0], -1, 0, output)); Assert.Throws<ArgumentOutOfRangeException> (() => encoder.Encode (new byte[1], 0, 10, output)); Assert.Throws<ArgumentNullException> (() => encoder.Encode (new byte[1], 0, 1, null)); Assert.Throws<ArgumentException> (() => encoder.Encode (new byte[1], 0, 1, output)); Assert.Throws<ArgumentNullException> (() => encoder.Flush (null, 0, 0, output)); Assert.Throws<ArgumentOutOfRangeException> (() => encoder.Flush (new byte[0], -1, 0, output)); Assert.Throws<ArgumentOutOfRangeException> (() => encoder.Flush (new byte[1], 0, 10, output)); Assert.Throws<ArgumentNullException> (() => encoder.Flush (new byte[1], 0, 1, null)); Assert.Throws<ArgumentException> (() => encoder.Flush (new byte[1], 0, 1, output)); }
static void CloneAndAssert (IMimeEncoder encoder) { // first, set some random state SetRandomState (encoder); var clone = encoder.Clone (); AssertState (encoder, clone); }