< Summary

Class:Azure.Messaging.ServiceBus.Primitives.PropertyDictionary
Assembly:Azure.Messaging.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Primitives\PropertyDictionary.cs
Covered lines:17
Uncovered lines:19
Coverable lines:36
Total lines:122
Line coverage:47.2% (17 of 36)
Covered branches:5
Total branches:8
Branch coverage:62.5% (5 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Keys()-0%100%
get_Values()-0%100%
get_Count()-100%100%
get_IsReadOnly()-0%100%
get_Item(...)-0%100%
set_Item(...)-0%0%
Add(...)-100%100%
ContainsKey(...)-0%100%
Remove(...)-0%100%
TryGetValue(...)-100%100%
Add(...)-0%100%
Clear()-0%100%
Contains(...)-0%100%
CopyTo(...)-0%100%
Remove(...)-0%100%
GetEnumerator()-100%100%
System.Collections.IEnumerable.GetEnumerator()-0%100%
IsSupportedObject(...)-80%75%
Clone()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Primitives\PropertyDictionary.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections;
 6using System.Collections.Generic;
 7using Azure.Messaging.ServiceBus.Amqp;
 8
 9namespace Azure.Messaging.ServiceBus.Primitives
 10{
 11    internal sealed class PropertyDictionary : IDictionary<string, object>
 12    {
 13        private readonly IDictionary<string, object> _inner;
 14
 13015        public PropertyDictionary()
 16        {
 13017            _inner = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
 13018        }
 19
 2420        public PropertyDictionary(IDictionary<string, object> container)
 21        {
 2422            _inner = container;
 2423        }
 24
 025        public ICollection<string> Keys => _inner.Keys;
 26
 027        public ICollection<object> Values => _inner.Values;
 28
 7629        public int Count => _inner.Count;
 30
 031        public bool IsReadOnly => _inner.IsReadOnly;
 32
 33        public object this[string key]
 34        {
 035            get => _inner[key];
 36
 37            set
 38            {
 039                if (IsSupportedObject(value))
 40                {
 041                    _inner[key] = value;
 42                }
 043            }
 44        }
 45
 46        public void Add(string key, object value)
 47        {
 17248            if (IsSupportedObject(value))
 49            {
 17250                _inner.Add(key, value);
 51            }
 17252        }
 53
 54        public bool ContainsKey(string key)
 55        {
 056            return _inner.ContainsKey(key);
 57        }
 58
 59        public bool Remove(string key)
 60        {
 061            return _inner.Remove(key);
 62        }
 63
 64        public bool TryGetValue(string key, out object value)
 65        {
 8866            return _inner.TryGetValue(key, out value);
 67        }
 68
 69        public void Add(KeyValuePair<string, object> item)
 70        {
 071            _inner.Add(item);
 072        }
 73
 74        public void Clear()
 75        {
 076            _inner.Clear();
 077        }
 78
 79        public bool Contains(KeyValuePair<string, object> item)
 80        {
 081            return _inner.Contains(item);
 82        }
 83
 84        public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
 85        {
 086            _inner.CopyTo(array, arrayIndex);
 087        }
 88
 89        public bool Remove(KeyValuePair<string, object> item)
 90        {
 091            return _inner.Remove(item);
 92        }
 93
 94        public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
 95        {
 8896            return _inner.GetEnumerator();
 97        }
 98
 99        IEnumerator IEnumerable.GetEnumerator()
 100        {
 0101            return _inner.GetEnumerator();
 102        }
 103
 104        private static bool IsSupportedObject(object value)
 105        {
 172106            if (value != null)
 107            {
 172108                var type = value.GetType();
 109
 172110                if (!SerializationUtilities.IsSupportedPropertyType(type))
 111                {
 0112                    throw new ArgumentException(Resources.NotSupportedPropertyType.FormatForUser(type), nameof(value));
 113                }
 114            }
 115
 172116            return true;
 117        }
 118
 119        internal PropertyDictionary Clone() =>
 24120            new PropertyDictionary(_inner);
 121    }
 122}