Пример #1
0
            public void WhenHasEmptyKey_ThenUseEmptyName()
            {
                var result = UriQueryConverter.ToDictionary("=value");

                Assert.That(result.Keys.Count, Is.EqualTo(1));
                Assert.That(result[string.Empty], Is.EqualTo("value"));
            }
Пример #2
0
            public void WhenValueContainsEquals_ThenReturnNameValues()
            {
                var result = UriQueryConverter.ToDictionary("?key1=value=1&key2=value2==");

                Assert.That(result.Count, Is.EqualTo(2));
                Assert.That(result["key1"], Is.EqualTo("value=1"));
                Assert.That(result["key2"], Is.EqualTo("value2=="));
            }
Пример #3
0
            public void WhenParamNameAndValueContainsEncodableChars_ThenDecodeNamesAndValues()
            {
                var result = UriQueryConverter.ToDictionary("?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"));
            }
Пример #4
0
            public void WhenValidQueryWithoutQuestionMark_ThenReturnNameValues()
            {
                var result = UriQueryConverter.ToDictionary("key1=value1&key2=value2");

                Assert.That(result.Count, Is.EqualTo(2));
                Assert.That(result["key1"], Is.EqualTo("value1"));
                Assert.That(result["key2"], Is.EqualTo("value2"));
            }
Пример #5
0
            public void WhenQueryNoValue_ThenReturnNameValues()
            {
                var result = UriQueryConverter.ToDictionary("?key1&key2&key3=value3");

                Assert.That(result.Count, Is.EqualTo(3));
                Assert.That(result["key1"], Is.Null);
                Assert.That(result["key2"], Is.Null);
                Assert.That(result["key3"], Is.EqualTo("value3"));
            }
Пример #6
0
            public void WhenIsNullOrEmptyOrQuestionMark_ThenReturnEmpty(string query)
            {
                var result = UriQueryConverter.ToDictionary(query);

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