Пример #1
0
            public void WhenHasMultipleSameNames_ThenReturnWithoutDuplicates()
            {
                var names = new List <string> {
                    "name1", "name2", "name1", "name3"
                };

                var result = UriQueryConverter.ToString(names);

                Assert.That(result, Is.EqualTo("?name1&name2&name3"));
            }
Пример #2
0
            public void WhenParamNamesContainEncodableChar_ThenEncodeNames()
            {
                var names = new List <string> {
                    "name1", "name 2", "name/3"
                };

                var result = UriQueryConverter.ToString(names);

                Assert.That(result, Is.EqualTo("?name1&name+2&name%2f3"));
            }
Пример #3
0
            public void WhenHasNullOrEmptyNames_ThenSkipName(string name)
            {
                var names = new List <string> {
                    name
                };

                var result = UriQueryConverter.ToString(names);

                Assert.That(result, Is.Empty);
            }
Пример #4
0
            public void WhenHasTwoNames_ThenReturnString()
            {
                var names = new List <string> {
                    "name1", "name2"
                };

                var result = UriQueryConverter.ToString(names);

                Assert.That(result, Is.EqualTo("?name1&name2"));
            }
Пример #5
0
            public void WhenHasOnePairWithValue_ThenReturnString()
            {
                var nameValues = new NameValueCollection
                {
                    { "key", "value" }
                };

                var result = UriQueryConverter.ToString(nameValues);

                Assert.That(result, Is.EqualTo("?key=value"));
            }
Пример #6
0
            public void WhenPairNameIsNullOrEmpty_ThenSkipPair(string name)
            {
                var nameValues = new NameValueCollection
                {
                    { name, "value" }
                };

                var result = UriQueryConverter.ToString(nameValues);

                Assert.That(result, Is.Empty);
            }
Пример #7
0
            public void WhenHasOnePair_ThenReturnString()
            {
                var dict = new Dictionary <string, string>
                {
                    { "key1", "value1" }
                };

                var result = UriQueryConverter.ToString(dict);

                Assert.That(result, Is.EqualTo("?key1=value1"));
            }
Пример #8
0
            public void WhenPairValueIsEmpty_ThenReturnString()
            {
                var dict = new Dictionary <string, string>
                {
                    { "key1", string.Empty }
                };

                var result = UriQueryConverter.ToString(dict);

                Assert.That(result, Is.EqualTo("?key1="));
            }
Пример #9
0
            public void WhenPairNameIsEmpty_ThenSkipPair()
            {
                var dict = new Dictionary <string, string>
                {
                    { string.Empty, "value" }
                };

                var result = UriQueryConverter.ToString(dict);

                Assert.That(result, Is.Empty);
            }
Пример #10
0
            public void WhenHasTwoPairs_ThenReturnString()
            {
                var nameValues = new NameValueCollection
                {
                    { "key1", "value1" },
                    { "key2", "value2" }
                };

                var result = UriQueryConverter.ToString(nameValues);

                Assert.That(result, Is.EqualTo("?key1=value1&key2=value2"));
            }
Пример #11
0
            public void WhenParamNameAndValueContainsEncodableChars_ThenReturnString()
            {
                var dict = new Dictionary <string, string>
                {
                    { "key1", "value1" },
                    { "key 2", "value 2" },
                    { "key/3", "value/3" }
                };

                var result = UriQueryConverter.ToString(dict);

                Assert.That(result, Is.EqualTo("?key1=value1&key+2=value+2&key%2f3=value%2f3"));
            }
Пример #12
0
            public void WhenParamNameAndValueContainsEncodableChars_ThenEncodeNamesAndValues()
            {
                var nameValues = new NameValueCollection
                {
                    { "key1", "value1" },
                    { "key 2", "value 2" },
                    { "key/3", "value/3" }
                };

                var result = UriQueryConverter.ToString(nameValues);

                Assert.That(result, Is.EqualTo("?key1=value1&key+2=value+2&key%2f3=value%2f3"));
            }
Пример #13
0
            public void WhenIsEmpty_ThenReturnEmpty()
            {
                var result = UriQueryConverter.ToString(new Dictionary <string, string>());

                Assert.That(result, Is.Empty);
            }
Пример #14
0
            public void WhenIsEmpty_ThenReturnEmpty()
            {
                var result = UriQueryConverter.ToString(new NameValueCollection());

                Assert.That(result, Is.Empty);
            }
Пример #15
0
            public void WhenIsNull_ThenReturnEmpty()
            {
                var result = UriQueryConverter.ToString(null as IEnumerable <string>);

                Assert.That(result, Is.Empty);
            }
Пример #16
0
            public void WhenIsEmpty_ThenReturnEmpty()
            {
                var result = UriQueryConverter.ToString(Enumerable.Empty <string>());

                Assert.That(result, Is.Empty);
            }
Пример #17
0
            public void WhenIsNull_ThenReturnEmpty()
            {
                var result = UriQueryConverter.ToString(null as IDictionary <string, string>);

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