public void Contains_AddValuesThenCallContains_ReturnsTrueForExistingItemsFalseOtherwise()
        {
            MockHeaders headers = new MockHeaders();
            HttpHeaderValueCollection <Uri> collection = new HttpHeaderValueCollection <Uri>(knownUriHeader, headers);

            collection.Add(new Uri("http://www.example.org/1/"));
            collection.Add(new Uri("http://www.example.org/2/"));
            collection.Add(new Uri("http://www.example.org/3/"));

            Assert.True(collection.Contains(new Uri("http://www.example.org/2/")), "Expected true for existing item.");
            Assert.False(collection.Contains(new Uri("http://www.example.org/4/")),
                         "Expected false for non-existing item.");
        }
        public void Contains_CallWithNullValue_Throw()
        {
            MockHeaders headers = new MockHeaders();
            HttpHeaderValueCollection <Uri> collection = new HttpHeaderValueCollection <Uri>(knownUriHeader, headers);

            Assert.Throws <ArgumentNullException>(() => { collection.Contains(null); });
        }
        public IActionConfiguration GetcontrollerActionConfiguration(Type controllerType, MethodInfo actionMethodInfo, HttpHeaderValueCollection<MediaTypeWithQualityHeaderValue> acceptHeaders)
        {
            if (!_controllerRules.ContainsKey(controllerType))
                return null;
            var controller = _controllerRules[controllerType];

            if (!controller.ContainsKey(actionMethodInfo))
                return null;

            var result = controller[actionMethodInfo];

            if ((acceptHeaders != null) && !acceptHeaders.Contains(new MediaTypeWithQualityHeaderValue(result.MetadataProvider.ContentType)))
                return null;

            return result;
        }
        public IActionConfiguration GetcontrollerActionConfiguration(Type controllerType, MethodInfo actionMethodInfo, HttpHeaderValueCollection <MediaTypeWithQualityHeaderValue> acceptHeaders)
        {
            if (!_controllerRules.ContainsKey(controllerType))
            {
                return(null);
            }
            var controller = _controllerRules[controllerType];

            if (!controller.ContainsKey(actionMethodInfo))
            {
                return(null);
            }

            var result = controller[actionMethodInfo];

            if ((acceptHeaders != null) && !acceptHeaders.Contains(new MediaTypeWithQualityHeaderValue(result.MetadataProvider.ContentType)))
            {
                return(null);
            }

            return(result);
        }
        public void Contains_AddValuesThenCallContains_ReturnsTrueForExistingItemsFalseOtherwise()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            collection.Add(new Uri("http://www.example.org/1/"));
            collection.Add(new Uri("http://www.example.org/2/"));
            collection.Add(new Uri("http://www.example.org/3/"));

            Assert.True(collection.Contains(new Uri("http://www.example.org/2/")), "Expected true for existing item.");
            Assert.False(collection.Contains(new Uri("http://www.example.org/4/")),
                "Expected false for non-existing item.");
        }
        public void Contains_CallWithNullValue_Throw()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers);

            Assert.Throws<ArgumentNullException>(() => { collection.Contains(null); });
        }