< Summary

Class:BaseVariable[T]
Assembly:BaseVariable
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/DataStore/Variables/BaseVariable.cs
Covered lines:8
Uncovered lines:2
Coverable lines:10
Total lines:31
Line coverage:80% (8 of 10)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BaseVariable()0%2100%
BaseVariable(...)0%2100%
Get()0%110100%
Set(...)0%110100%
Set(...)0%330100%
Equals(...)0%110100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4public delegate void Change<T>(T current, T previous);
 5
 6public class BaseVariable<T> : IBaseVariable<T>, IEquatable<T>
 7{
 8    public event Change<T> OnChange;
 9
 10    protected T value;
 11
 012    public BaseVariable() { value = default; }
 013    public BaseVariable(T defaultValue) { value = defaultValue; }
 14
 615    public T Get() { return value; }
 16
 1709217    public void Set(T newValue) { Set(newValue, !Equals(newValue)); }
 18
 19    public void Set(T newValue, bool notifyEvent)
 20    {
 865821        var previous = value;
 865822        value = newValue;
 23
 865824        if (notifyEvent)
 25        {
 362726            OnChange?.Invoke(value, previous);
 27        }
 566028    }
 29
 854030    public virtual bool Equals(T other) { return EqualityComparer<T>.Default.Equals(value, other); }
 31}