< Summary

Class:Azure.Storage.UriQueryParamsCollection
Assembly:Azure.Storage.Common
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\UriQueryParamsCollection.cs
Covered lines:10
Uncovered lines:8
Coverable lines:18
Total lines:60
Line coverage:55.5% (10 of 18)
Covered branches:6
Total branches:12
Branch coverage:50% (6 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
.ctor(...)-90.91%75%
ToString()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\UriQueryParamsCollection.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Globalization;
 7using System.Net;
 8using System.Text;
 9
 10namespace Azure.Storage
 11{
 12    internal sealed class UriQueryParamsCollection : Dictionary<string, string>
 13    {
 014        public UriQueryParamsCollection() : base(StringComparer.OrdinalIgnoreCase) { }
 15
 16        /// <summary>
 17        /// Takes encoded query params string, output decoded params map
 18        /// </summary>
 19        /// <param name="encodedQueryParamString"></param>
 4420    public UriQueryParamsCollection(string encodedQueryParamString)
 21        {
 4422            encodedQueryParamString = encodedQueryParamString ?? throw Errors.ArgumentNull(nameof(encodedQueryParamStrin
 23
 4424            if (encodedQueryParamString.StartsWith("?", true, CultureInfo.InvariantCulture))
 25            {
 4426                encodedQueryParamString = encodedQueryParamString.Substring(1);
 27            }
 28
 4429            var keysAndValues = encodedQueryParamString.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
 22430            foreach (var qp in keysAndValues)
 31            {
 6832                var keyAndValue = qp.Split(new[] { '=' }, 2);
 6833                if (keyAndValue.Length == 1)
 34                {
 035                    Add(WebUtility.UrlDecode(keyAndValue[0]), default); // The map's keys/values are url-decoded
 36                }
 37                else
 38                {
 6839                    Add(WebUtility.UrlDecode(keyAndValue[0]), WebUtility.UrlDecode(keyAndValue[1])); // The map's keys/v
 40                }
 41            }
 4442        }
 43
 44        // Returns the url-encoded query parameter string
 45        public override string ToString()
 46        {
 047            var sb = new StringBuilder();
 048            foreach (KeyValuePair<string, string> kv in this)
 49            {
 050                if (sb.Length > 0)
 51                {
 052                    sb.Append('&');
 53                }
 54
 055                sb.Append(WebUtility.UrlEncode(kv.Key)).Append('=').Append(WebUtility.UrlEncode(kv.Value));   // Query p
 56            }
 057            return sb.ToString();
 58        }
 59    }
 60}

Methods/Properties

.ctor()
.ctor(...)
ToString()