< Summary

Class:BaseDictionary[TKey,TValue]
Assembly:DataStore
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/DataStore/Variables/BaseDictionary.cs
Covered lines:28
Uncovered lines:4
Coverable lines:32
Total lines:70
Line coverage:87.5% (28 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BaseDictionary()0%110100%
BaseDictionary(...)0%330100%
Get()0%2100%
Get(...)0%110100%
TryGetValue(...)0%110100%
Set(...)0%440100%
Add(...)0%220100%
Remove(...)0%330100%
Clear()0%2.152066.67%
ContainsKey(...)0%110100%
ContainsValue(...)0%2100%
Count()0%2100%
GetValues()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/DataStore/Variables/BaseDictionary.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4
 5public class BaseDictionary<TKey, TValue> : IBaseDictionary<TKey, TValue>
 6{
 7    public event Action<IEnumerable<KeyValuePair<TKey, TValue>>> OnSet;
 8    public event Action<TKey, TValue> OnAdded;
 9    public event Action<TKey, TValue> OnRemoved;
 10
 43211    internal readonly Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>();
 12
 12313    public TValue this[TKey key] { get => dictionary[key]; set => dictionary[key] = value; }
 14
 86015    public BaseDictionary() { }
 216    public BaseDictionary(IEnumerable<(TKey, TValue)> elements)
 17    {
 218        dictionary = new Dictionary<TKey, TValue>();
 1419        foreach ((TKey key, TValue value) in elements)
 20        {
 521            dictionary.Add(key, value);
 22        }
 223    }
 24
 025    public IEnumerable<KeyValuePair<TKey, TValue>> Get() => dictionary;
 26
 2127    public TValue Get(TKey key) => dictionary[key];
 28
 109429    public bool TryGetValue(TKey key, out TValue value) => dictionary.TryGetValue(key, out value);
 30
 31    public void Set(IEnumerable<(TKey, TValue)> elements)
 32    {
 5933        dictionary.Clear();
 25434        foreach ((TKey key, TValue value) in elements)
 35        {
 6836            dictionary.Add(key, value);
 37        }
 5938        OnSet?.Invoke(dictionary);
 539    }
 40
 41    public void Add(TKey key, TValue value)
 42    {
 214243        dictionary.Add(key, value);
 214244        OnAdded?.Invoke(key, value);
 1345    }
 46
 47    public bool Remove(TKey key)
 48    {
 6149        if (!dictionary.ContainsKey(key))
 1150            return false;
 51
 5052        TValue value = dictionary[key];
 5053        dictionary.Remove(key);
 5054        OnRemoved?.Invoke(key, value);
 5055        return true;
 56    }
 57
 58    public void Clear()
 59    {
 27060        dictionary.Clear();
 27061        OnSet?.Invoke(new Dictionary<TKey, TValue>());
 062    }
 63
 9164    public bool ContainsKey(TKey key) => dictionary.ContainsKey(key);
 065    public bool ContainsValue(TValue value) => dictionary.ContainsValue(value);
 66
 067    public int Count() => dictionary.Count;
 68
 7369    public List<TValue> GetValues() => dictionary.Values.ToList();
 70}