< Summary

Class:BaseCollection[T]
Assembly:DataStore
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/DataStore/Variables/BaseCollection.cs
Covered lines:19
Uncovered lines:5
Coverable lines:24
Total lines:55
Line coverage:79.1% (19 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BaseCollection()0%110100%
BaseCollection(...)0%110100%
Get()0%2100%
Set(...)0%220100%
Add(...)0%220100%
Remove(...)0%330100%
RemoveAt(...)0%220100%
ElementAt(...)0%2100%
Count()0%2100%
Contains(...)0%110100%
Equals(...)0%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4public class BaseCollection<T> : IBaseCollection<T>, IEquatable<IEnumerable<T>>
 5{
 6    public event Action<IEnumerable<T>> OnSet;
 7    public event Action<T> OnAdded;
 8    public event Action<T> OnRemoved;
 9
 410    internal readonly List<T> list = new List<T>();
 11
 212    public BaseCollection() { }
 913    public BaseCollection(IEnumerable<T> elements) { list = new List<T>(elements); }
 14
 015    public IEnumerable<T> Get() => list;
 16
 017    public T this[int index] { get => list[index]; set => list[index] = value; }
 18
 19    public void Set(IEnumerable<T> elements)
 20    {
 921        list.Clear();
 922        list.AddRange(elements);
 23
 924        OnSet?.Invoke(list);
 225    }
 26
 27    public void Add(T element)
 28    {
 3629        list.Add(element);
 3630        OnAdded?.Invoke(element);
 631    }
 32
 33    public bool Remove(T element)
 34    {
 935        if (!list.Remove(element))
 236            return false;
 37
 738        OnRemoved?.Invoke(element);
 739        return true;
 40    }
 41
 42    public void RemoveAt(int index)
 43    {
 344        T value = list[index];
 345        list.RemoveAt(index);
 346        OnRemoved?.Invoke(value);
 147    }
 48
 049    public T ElementAt(int index) => list[index];
 050    public int Count() => list.Count;
 51
 3052    public bool Contains(T element) => list.Contains(element);
 53
 054    public virtual bool Equals(IEnumerable<T> other) { return EqualityComparer<IEnumerable<T>>.Default.Equals(list, othe
 55}