コード例 #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;
        }
コード例 #2
0
ファイル: EncoderTests.cs プロジェクト: surekqomi/MimeKit
        static void CloneAndAssert(IMimeEncoder encoder)
        {
            // first, set some random state
            SetRandomState(encoder);

            var clone = encoder.Clone();

            AssertState(encoder, clone);

            AssertArgumentExceptions(encoder);
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #5
0
ファイル: EncoderFilter.cs プロジェクト: jomarsupsup/MimeKit
 /// <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;
 }
コード例 #6
0
ファイル: EncoderFilter.cs プロジェクト: gphummer/MimeKit
		/// <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;
		}
コード例 #7
0
ファイル: EncoderTests.cs プロジェクト: jstedfast/MimeKit
		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);
		}
コード例 #8
0
ファイル: EncoderTests.cs プロジェクト: jstedfast/MimeKit
		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);
		}
コード例 #9
0
ファイル: EncoderTests.cs プロジェクト: jstedfast/MimeKit
		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));
		}
コード例 #10
0
ファイル: EncoderTests.cs プロジェクト: dcga/MimeKit
		static void CloneAndAssert (IMimeEncoder encoder)
		{
			// first, set some random state
			SetRandomState (encoder);

			var clone = encoder.Clone ();

			AssertState (encoder, clone);
		}