public void TryMatchMediaTypeReturnsFalseWithMediaRangeNotInAcceptHeader(string mediaRange, string mediaType)
        {
            MediaRangeMapping  mapping = new MediaRangeMapping(mediaRange, mediaType);
            HttpRequestMessage request = new HttpRequestMessage();

            Assert.Equal(0.0, mapping.TryMatchMediaType(request));
        }
        public void TryMatchMediaTypeReturnsOneWithMediaRangeInAcceptHeader(string mediaRange, string mediaType)
        {
            MediaRangeMapping  mapping = new MediaRangeMapping(mediaRange, mediaType);
            HttpRequestMessage request = new HttpRequestMessage();

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(mediaRange));
            Assert.Equal(1.0, mapping.TryMatchMediaType(request));
        }
        public void TryMatchMediaTypeReturnsQualityWithMediaRangeWithQualityInAcceptHeader(MediaTypeWithQualityHeaderValue mediaRangeWithQuality, MediaTypeHeaderValue mediaType)
        {
            MediaTypeWithQualityHeaderValue mediaRangeWithNoQuality = new MediaTypeWithQualityHeaderValue(mediaRangeWithQuality.MediaType);
            MediaRangeMapping  mapping = new MediaRangeMapping(mediaRangeWithNoQuality, mediaType);
            HttpRequestMessage request = new HttpRequestMessage();

            request.Headers.Accept.Add(mediaRangeWithQuality);
            double quality = mediaRangeWithQuality.Quality.Value;

            Assert.Equal(quality, mapping.TryMatchMediaType(request));
        }
        public void TryMatchMediaTypeThrowsWithNullHttpRequestMessage(string mediaRange, string mediaType)
        {
            MediaRangeMapping mapping = new MediaRangeMapping(mediaRange, mediaType);

            Assert.ThrowsArgumentNull(() => mapping.TryMatchMediaType(request: null), "request");
        }
 public void TryMatchMediaTypeReturnsFalseWithMediaRangeNotInAcceptHeader(string mediaRange, string mediaType)
 {
     MediaRangeMapping mapping = new MediaRangeMapping(mediaRange, mediaType);
     HttpRequestMessage request = new HttpRequestMessage();
     Assert.Equal(0.0, mapping.TryMatchMediaType(request));
 }
 public void TryMatchMediaTypeReturnsQualityWithMediaRangeWithQualityInAcceptHeader(MediaTypeWithQualityHeaderValue mediaRangeWithQuality, MediaTypeHeaderValue mediaType)
 {
     MediaTypeWithQualityHeaderValue mediaRangeWithNoQuality = new MediaTypeWithQualityHeaderValue(mediaRangeWithQuality.MediaType);
     MediaRangeMapping mapping = new MediaRangeMapping(mediaRangeWithNoQuality, mediaType);
     HttpRequestMessage request = new HttpRequestMessage();
     request.Headers.Accept.Add(mediaRangeWithQuality);
     double quality = mediaRangeWithQuality.Quality.Value;
     Assert.Equal(quality, mapping.TryMatchMediaType(request));
 }
 public void TryMatchMediaTypeReturnsOneWithMediaRangeInAcceptHeader(string mediaRange, string mediaType)
 {
     MediaRangeMapping mapping = new MediaRangeMapping(mediaRange, mediaType);
     HttpRequestMessage request = new HttpRequestMessage();
     request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(mediaRange));
     Assert.Equal(1.0, mapping.TryMatchMediaType(request));
 }
 public void TryMatchMediaTypeThrowsWithNullHttpRequestMessage(string mediaRange, string mediaType)
 {
     MediaRangeMapping mapping = new MediaRangeMapping(mediaRange, mediaType);
     Assert.ThrowsArgumentNull(() => mapping.TryMatchMediaType(request: null), "request");
 }