/// <summary> /// Initializes a new instance of the <see cref="MimeKit.IO.Filters.DecoderFilter"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="DecoderFilter"/> using the specified decoder. /// </remarks> /// <param name="decoder">A specific decoder for the filter to use.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="decoder"/> is <c>null</c>. /// </exception> public DecoderFilter (IMimeDecoder decoder) { if (decoder == null) throw new ArgumentNullException ("decoder"); Decoder = decoder; }
/// <summary> /// Initializes a new instance of the <see cref="MimeKit.IO.Filters.DecoderFilter"/> class. /// </summary> /// <remarks> /// Creates a new <see cref="DecoderFilter"/> using the specified decoder. /// </remarks> /// <param name="decoder">A specific decoder for the filter to use.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="decoder"/> is <c>null</c>. /// </exception> public DecoderFilter(IMimeDecoder decoder) { if (decoder == null) { throw new ArgumentNullException(nameof(decoder)); } Decoder = decoder; }
static void AssertArgumentExceptions(IMimeDecoder decoder) { var output = new byte[0]; Assert.Throws <ArgumentNullException> (() => decoder.Decode(null, 0, 0, output)); Assert.Throws <ArgumentOutOfRangeException> (() => decoder.Decode(new byte[0], -1, 0, output)); Assert.Throws <ArgumentOutOfRangeException> (() => decoder.Decode(new byte[1], 0, 10, output)); Assert.Throws <ArgumentNullException> (() => decoder.Decode(new byte[1], 0, 1, null)); Assert.Throws <ArgumentException> (() => decoder.Decode(new byte[1], 0, 1, output)); }
static void CloneAndAssert(IMimeDecoder decoder) { // first, set some random state SetRandomState(decoder); var clone = decoder.Clone(); AssertState(decoder, clone); AssertArgumentExceptions(decoder); }
static void ResetAndAssert(IMimeDecoder decoder) { // clone the decoder at it's initial state var clone = decoder.Clone(); // set some random state on the clone SetRandomState(clone); // reset the clone and make sure it matches clone.Reset(); AssertState(decoder, clone); }
static unsafe int DecodeToken (Token token, IMimeDecoder decoder, byte* input, byte* output) { byte* inptr = input + token.StartIndex; return decoder.Decode (inptr, token.Length, output); }
static void ResetAndAssert (IMimeDecoder decoder) { // clone the decoder at it's initial state var clone = decoder.Clone (); // set some random state on the clone SetRandomState (clone); // reset the clone and make sure it matches clone.Reset (); AssertState (decoder, clone); }
static void CloneAndAssert (IMimeDecoder decoder) { // first, set some random state SetRandomState (decoder); var clone = decoder.Clone (); AssertState (decoder, clone); AssertArgumentExceptions (decoder); }
static void AssertArgumentExceptions (IMimeDecoder decoder) { var output = new byte[0]; Assert.Throws<ArgumentNullException> (() => decoder.Decode (null, 0, 0, output)); Assert.Throws<ArgumentOutOfRangeException> (() => decoder.Decode (new byte[0], -1, 0, output)); Assert.Throws<ArgumentOutOfRangeException> (() => decoder.Decode (new byte[1], 0, 10, output)); Assert.Throws<ArgumentNullException> (() => decoder.Decode (new byte[1], 0, 1, null)); Assert.Throws<ArgumentException> (() => decoder.Decode (new byte[1], 0, 1, output)); }