< Summary

Information
Class: OffRouteMap.ProviderCollection
Assembly: OffRouteMap
File(s): D:\a\OffRouteMap\OffRouteMap\ProviderCollection.cs
Tag: 5_18712131505
Line coverage
80%
Covered lines: 4
Uncovered lines: 1
Coverable lines: 5
Total lines: 31
Line coverage: 80%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Item(...)100%210%
TryGet(...)50%22100%

File(s)

D:\a\OffRouteMap\OffRouteMap\ProviderCollection.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Collections.ObjectModel;
 4using System.Linq;
 5using System.Text;
 6using System.Threading.Tasks;
 7
 8namespace OffRouteMap
 9{
 10    /// <summary>
 11    /// A class to store many provider details as item.
 12    /// </summary>
 13    public class ProviderCollection : ObservableCollection<ProviderItem>
 14    {
 15        private readonly Dictionary<string, ProviderItem> _byKey;
 16
 17        public ProviderCollection (IEnumerable<ProviderItem> items)
 418            : base(items)
 19        {
 2020            _byKey = this.ToDictionary(p => p.Key, StringComparer.OrdinalIgnoreCase);
 421        }
 22
 23        public ProviderItem this[string key]
 24        {
 025            get => _byKey[key];
 26        }
 27
 28        public bool TryGet (string key, out ProviderItem item) =>
 429            _byKey.TryGetValue(key ?? string.Empty, out item);
 30    }
 31}