< Summary

Class:BaseList[TValue]
Assembly:BaseVariable
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/DataStore/Variables/BaseList.cs
Covered lines:12
Uncovered lines:17
Coverable lines:29
Total lines:82
Line coverage:41.3% (12 of 29)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BaseList()0%110100%
BaseList(...)0%110100%
GetEnumerator()0%2100%
GetEnumerator()0%2100%
Add(...)0%220100%
Clear()0%2100%
Contains(...)0%2100%
CopyTo(...)0%2100%
Remove(...)0%3.143075%
IndexOf(...)0%2100%
Insert(...)0%6200%
RemoveAt(...)0%6200%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4
 5public class BaseList<TValue> : IList<TValue>, IReadOnlyList<TValue>
 6{
 7    private readonly List<TValue> list;
 8
 9    public event Action<TValue> OnAdded;
 10    public event Action<TValue> OnRemoved;
 11
 9612    public TValue this[int index] { get => list[index]; set => list[index] = value; }
 13
 9914    public int Count => list.Count;
 15
 016    public bool IsReadOnly => false;
 17
 79818    public BaseList() : this(0) { }
 19
 39920    public BaseList(int capacity)
 21    {
 39922        list = new List<TValue>(capacity);
 39923    }
 24
 25    public IEnumerator<TValue> GetEnumerator()
 26    {
 027        return list.GetEnumerator();
 28    }
 29
 30    IEnumerator IEnumerable.GetEnumerator()
 31    {
 032        return GetEnumerator();
 33    }
 34
 35    public void Add(TValue item)
 36    {
 3537        list.Add(item);
 3538        OnAdded?.Invoke(item);
 339    }
 40
 41    public void Clear()
 42    {
 043        list.Clear();
 044    }
 45
 46    public bool Contains(TValue item)
 47    {
 048        return list.Contains(item);
 49    }
 50
 51    public void CopyTo(TValue[] array, int arrayIndex)
 52    {
 053        list.CopyTo(array, arrayIndex);
 054    }
 55
 56    public bool Remove(TValue item)
 57    {
 158        if (!list.Remove(item))
 059            return false;
 60
 161        OnRemoved?.Invoke(item);
 162        return true;
 63    }
 64
 65    public int IndexOf(TValue item)
 66    {
 067        return list.IndexOf(item);
 68    }
 69
 70    public void Insert(int index, TValue item)
 71    {
 072        list.Insert(index, item);
 073        OnAdded?.Invoke(item);
 074    }
 75
 76    public void RemoveAt(int index)
 77    {
 078        TValue item = list[index];
 079        list.RemoveAt(index);
 080        OnRemoved?.Invoke(item);
 081    }
 82}