< Summary

Class:Azure.Storage.UriQueryParamsCollection
Assembly:Azure.Storage.Files.DataLake
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\UriQueryParamsCollection.cs
Covered lines:17
Uncovered lines:1
Coverable lines:18
Total lines:60
Line coverage:94.4% (17 of 18)
Covered branches:11
Total branches:12
Branch coverage:91.6% (11 of 12)

Metrics

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

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>
 2487220    public UriQueryParamsCollection(string encodedQueryParamString)
 21        {
 2487222            encodedQueryParamString = encodedQueryParamString ?? throw Errors.ArgumentNull(nameof(encodedQueryParamStrin
 23
 2487224            if (encodedQueryParamString.StartsWith("?", true, CultureInfo.InvariantCulture))
 25            {
 1204026                encodedQueryParamString = encodedQueryParamString.Substring(1);
 27            }
 28
 2487229            var keysAndValues = encodedQueryParamString.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
 8455230            foreach (var qp in keysAndValues)
 31            {
 1740432                var keyAndValue = qp.Split(new[] { '=' }, 2);
 1740433                if (keyAndValue.Length == 1)
 34                {
 20035                    Add(WebUtility.UrlDecode(keyAndValue[0]), default); // The map's keys/values are url-decoded
 36                }
 37                else
 38                {
 1720439                    Add(WebUtility.UrlDecode(keyAndValue[0]), WebUtility.UrlDecode(keyAndValue[1])); // The map's keys/v
 40                }
 41            }
 2487242        }
 43
 44        // Returns the url-encoded query parameter string
 45        public override string ToString()
 46        {
 1229447            var sb = new StringBuilder();
 2718848            foreach (KeyValuePair<string, string> kv in this)
 49            {
 130050                if (sb.Length > 0)
 51                {
 96452                    sb.Append('&');
 53                }
 54
 130055                sb.Append(WebUtility.UrlEncode(kv.Key)).Append('=').Append(WebUtility.UrlEncode(kv.Value));   // Query p
 56            }
 1229457            return sb.ToString();
 58        }
 59    }
 60}

Methods/Properties

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