Example #1
0
            public void WhenHasEmptyKey_ThenUseEmptyName()
            {
                var result = UriQueryConverter.ToNameValueCollection("=value");

                Assert.That(result.AllKeys.Length, Is.EqualTo(1));
                Assert.That(result[string.Empty], Is.EqualTo("value"));
            }
Example #2
0
            public void WhenValueContainsEquals_ThenReturnNameValues()
            {
                var result = UriQueryConverter.ToNameValueCollection("?key1=value=1&key2=value2==");

                Assert.That(result.AllKeys.Length, Is.EqualTo(2));
                Assert.That(result["key1"], Is.EqualTo("value=1"));
                Assert.That(result["key2"], Is.EqualTo("value2=="));
            }
Example #3
0
            public void WhenParamNameAndValueContainsEncodableChars_ThenDecodeNamesAndValues()
            {
                var result = UriQueryConverter.ToNameValueCollection("?key1=value1&key+2=value+2&key%2f3=value%2f3");

                Assert.That(result["key1"], Is.EqualTo("value1"));
                Assert.That(result["key 2"], Is.EqualTo("value 2"));
                Assert.That(result["key/3"], Is.EqualTo("value/3"));
            }
Example #4
0
            public void WhenWithQuestionMark_ThenReturnNameValues()
            {
                var result = UriQueryConverter.ToNameValueCollection("?key1=value1&key2=value2");

                Assert.That(result.AllKeys.Length, Is.EqualTo(2));
                Assert.That(result["key1"], Is.EqualTo("value1"));
                Assert.That(result["key2"], Is.EqualTo("value2"));
            }
Example #5
0
            public void WhenQueryNoValue_ThenReturnNameValues()
            {
                var result = UriQueryConverter.ToNameValueCollection("?key1&key2&key3=value3");

                Assert.That(result.AllKeys.Length, Is.EqualTo(3));
                Assert.That(result["key1"], Is.Null);
                Assert.That(result["key2"], Is.Null);
                Assert.That(result["key3"], Is.EqualTo("value3"));
            }
Example #6
0
            public void WhenIsNullOrEmptyOrQuestionMark_ThenReturnEmpty(string query)
            {
                var result = UriQueryConverter.ToNameValueCollection(query);

                Assert.That(result, Is.Empty);
            }