/// <summary> /// Remove the specified filter. /// </summary> /// <remarks> /// Removes the specified filter from the list if it exists. /// </remarks> /// <returns><value>true</value> if the filter was removed; otherwise <value>false</value>.</returns> /// <param name="filter">The filter.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="filter"/> is <c>null</c>. /// </exception> public bool Remove(IMimeFilter filter) { if (filter == null) { throw new ArgumentNullException("filter"); } return(filters.Remove(filter)); }
/// <summary> /// Adds the specified filter. /// </summary> /// <remarks> /// Adds the <paramref name="filter"/> to the end of the list of filters /// that data will pass through as data is read from or written to the /// underlying source stream. /// </remarks> /// <param name="filter">The filter.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="filter"/> is <c>null</c>. /// </exception> public void Add(IMimeFilter filter) { if (filter == null) { throw new ArgumentNullException("filter"); } filters.Add(filter); }
/// <summary> /// Checks if the filtered stream contains the specified filter. /// </summary> /// <remarks> /// Determines whether or not the filtered stream contains the specified filter. /// </remarks> /// <returns><value>true</value> if the specified filter exists; /// otherwise <value>false</value>.</returns> /// <param name="filter">The filter.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="filter"/> is <c>null</c>. /// </exception> public bool Contains(IMimeFilter filter) { if (filter == null) { throw new ArgumentNullException("filter"); } return(filters.Contains(filter)); }
static void TestArgumentExceptions(IMimeFilter filter) { int outputIndex, outputLength; var buffer = new byte[10]; Assert.Throws <ArgumentNullException> (() => filter.Filter(null, 0, 0, out outputIndex, out outputLength)); Assert.Throws <ArgumentOutOfRangeException> (() => filter.Filter(buffer, -1, 0, out outputIndex, out outputLength)); Assert.Throws <ArgumentOutOfRangeException> (() => filter.Filter(buffer, 0, 20, out outputIndex, out outputLength)); Assert.Throws <ArgumentNullException> (() => filter.Flush(null, 0, 0, out outputIndex, out outputLength)); Assert.Throws <ArgumentOutOfRangeException> (() => filter.Flush(buffer, -1, 0, out outputIndex, out outputLength)); Assert.Throws <ArgumentOutOfRangeException> (() => filter.Flush(buffer, 0, 20, out outputIndex, out outputLength)); }
static void AssertFilterArguments(IMimeFilter filter) { int outputIndex, outputLength; var input = new byte[1024]; ArgumentException ex; // Filter Assert.Throws <ArgumentNullException> (() => filter.Filter(null, 0, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentNullException when input was null.", filter.GetType().Name); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Filter(input, -1, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was -1.", filter.GetType().Name); Assert.AreEqual("startIndex", ex.ParamName); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Filter(input, 0, -1, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was -1.", filter.GetType().Name); Assert.AreEqual("length", ex.ParamName); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Filter(input, 1025, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was > 1024.", filter.GetType().Name); Assert.AreEqual("startIndex", ex.ParamName); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Filter(input, 0, 1025, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was > 1024.", filter.GetType().Name); Assert.AreEqual("length", ex.ParamName); // Flush Assert.Throws <ArgumentNullException> (() => filter.Flush(null, 0, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentNullException when input was null.", filter.GetType().Name); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Flush(input, -1, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was -1.", filter.GetType().Name); Assert.AreEqual("startIndex", ex.ParamName); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Flush(input, 0, -1, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was -1.", filter.GetType().Name); Assert.AreEqual("length", ex.ParamName); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Flush(input, 1025, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was > 1024.", filter.GetType().Name); Assert.AreEqual("startIndex", ex.ParamName); ex = Assert.Throws <ArgumentOutOfRangeException> (() => filter.Flush(input, 0, 1025, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was > 1024.", filter.GetType().Name); Assert.AreEqual("length", ex.ParamName); filter.Reset(); }
static void AssertFilterArguments (IMimeFilter filter) { int outputIndex, outputLength; var input = new byte[1024]; ArgumentException ex; // Filter Assert.Throws<ArgumentNullException> (() => filter.Filter (null, 0, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentNullException when input was null.", filter.GetType ().Name); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Filter (input, -1, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was -1.", filter.GetType ().Name); Assert.AreEqual ("startIndex", ex.ParamName); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Filter (input, 0, -1, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was -1.", filter.GetType ().Name); Assert.AreEqual ("length", ex.ParamName); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Filter (input, 1025, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was > 1024.", filter.GetType ().Name); Assert.AreEqual ("startIndex", ex.ParamName); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Filter (input, 0, 1025, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was > 1024.", filter.GetType ().Name); Assert.AreEqual ("length", ex.ParamName); // Flush Assert.Throws<ArgumentNullException> (() => filter.Flush (null, 0, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentNullException when input was null.", filter.GetType ().Name); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Flush (input, -1, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was -1.", filter.GetType ().Name); Assert.AreEqual ("startIndex", ex.ParamName); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Flush (input, 0, -1, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was -1.", filter.GetType ().Name); Assert.AreEqual ("length", ex.ParamName); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Flush (input, 1025, 0, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when startIndex was > 1024.", filter.GetType ().Name); Assert.AreEqual ("startIndex", ex.ParamName); ex = Assert.Throws<ArgumentOutOfRangeException> (() => filter.Flush (input, 0, 1025, out outputIndex, out outputLength), "{0}.Filter did not throw ArgumentOutOfRangeException when length was > 1024.", filter.GetType ().Name); Assert.AreEqual ("length", ex.ParamName); }
/// <summary> /// Remove the specified filter. /// </summary> /// <remarks> /// Removes the specified filter from the list if it exists. /// </remarks> /// <returns><value>true</value> if the filter was removed; otherwise <value>false</value>.</returns> /// <param name="filter">The filter.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="filter"/> is <c>null</c>. /// </exception> public bool Remove (IMimeFilter filter) { if (filter == null) throw new ArgumentNullException ("filter"); return filters.Remove (filter); }
/// <summary> /// Checks if the filtered stream contains the specified filter. /// </summary> /// <remarks> /// Determines whether or not the filtered stream contains the specified filter. /// </remarks> /// <returns><value>true</value> if the specified filter exists; /// otherwise <value>false</value>.</returns> /// <param name="filter">The filter.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="filter"/> is <c>null</c>. /// </exception> public bool Contains (IMimeFilter filter) { if (filter == null) throw new ArgumentNullException ("filter"); return filters.Contains (filter); }
/// <summary> /// Adds the specified filter. /// </summary> /// <remarks> /// Adds the <paramref name="filter"/> to the end of the list of filters /// that data will pass through as data is read from or written to the /// underlying source stream. /// </remarks> /// <param name="filter">The filter.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="filter"/> is <c>null</c>. /// </exception> public void Add (IMimeFilter filter) { if (filter == null) throw new ArgumentNullException ("filter"); filters.Add (filter); }