public void FindAllContentTypeMediaTypeThrows()
        {
            Assert.ThrowsArgumentNull(() => { HttpContentCollectionExtensions.FindAllContentType(null, new MediaTypeHeaderValue("text/plain")); }, "contents");

            IEnumerable <HttpContent> content = HttpContentCollectionExtensionsTests.CreateContent();

            Assert.ThrowsArgumentNull(() => { HttpContentCollectionExtensions.FindAllContentType(content, (MediaTypeHeaderValue)null); }, "contentType");
        }
        /// <summary>
        /// Returns all instances of <see cref="HttpContent"/> in a sequence that has a <see cref="MediaTypeHeaderValue"/> header field
        /// with a <see cref="MediaTypeHeaderValue.MediaType"/> property equal to the provided <paramref name="contentType"/>.
        /// </summary>
        /// <param name="contents">The content to evaluate</param>
        /// <param name="contentType">The media type to look for.</param>
        /// <returns>null if source is empty or if no element matches; otherwise the first <see cref="HttpContent"/> in
        /// the sequence with a matching media type.</returns>
        public static IEnumerable <HttpContent> FindAllContentType(this IEnumerable <HttpContent> contents, string contentType)
        {
            if (String.IsNullOrWhiteSpace(contentType))
            {
                throw new ArgumentNullException("contentType");
            }

            return(HttpContentCollectionExtensions.FindAllContentType(contents, new MediaTypeHeaderValue(contentType)));
        }
        public void FindAllContentTypeString()
        {
            Assert.ThrowsArgumentNull(() => { HttpContentCollectionExtensions.FindAllContentType(null, "text/plain"); }, "contents");

            IEnumerable <HttpContent> content = HttpContentCollectionExtensionsTests.CreateContent();

            Assert.ThrowsArgumentNull(() => { HttpContentCollectionExtensions.FindAllContentType(content, (string)null); }, "contentType");
            foreach (string empty in TestData.EmptyStrings)
            {
                Assert.ThrowsArgumentNull(() => { HttpContentCollectionExtensions.FindAllContentType(content, empty); }, "contentType");
            }
        }
        /// <summary>
        /// Returns all instances of <see cref="HttpContent"/> in a sequence that has a <see cref="MediaTypeHeaderValue"/> header field
        /// with a <see cref="MediaTypeHeaderValue.MediaType"/> property equal to the provided <paramref name="contentType"/>.
        /// </summary>
        /// <param name="contents">The content to evaluate</param>
        /// <param name="contentType">The media type to look for.</param>
        /// <returns>null if source is empty or if no element matches; otherwise the first <see cref="HttpContent"/> in
        /// the sequence with a matching media type.</returns>
        public static IEnumerable <HttpContent> FindAllContentType(this IEnumerable <HttpContent> contents, MediaTypeHeaderValue contentType)
        {
            if (contents == null)
            {
                throw new ArgumentNullException("contents");
            }

            if (contentType == null)
            {
                throw new ArgumentNullException("contentType");
            }

            return(contents.Where((item) =>
            {
                return HttpContentCollectionExtensions.FindAllContentType(item, contentType);
            }));
        }