Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        static void CloneAndAssert(IMimeEncoder encoder)
        {
            // first, set some random state
            SetRandomState(encoder);

            var clone = encoder.Clone();

            AssertState(encoder, clone);

            AssertArgumentExceptions(encoder);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 /// <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;
 }
Exemplo n.º 6
0
		/// <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;
		}
Exemplo n.º 7
0
		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);
		}
Exemplo n.º 8
0
		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);
		}
Exemplo n.º 9
0
		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));
		}
Exemplo n.º 10
0
		static void CloneAndAssert (IMimeEncoder encoder)
		{
			// first, set some random state
			SetRandomState (encoder);

			var clone = encoder.Clone ();

			AssertState (encoder, clone);
		}