< Summary

Class:DCL.Components.UIValue
Assembly:DCL.Components.UI.Interfaces
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UI/Interfaces/UIValue.cs
Covered lines:7
Uncovered lines:7
Coverable lines:14
Total lines:47
Line coverage:50% (7 of 14)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:4
Method coverage:50% (2 of 4)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetPixels(...)0%2100%
SetPercent(...)0%2100%
UIValue(...)0%110100%
GetScaledValue(...)0%3.073080%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UI/Interfaces/UIValue.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.Components
 4{
 5    [System.Serializable]
 6    public struct UIValue
 7    {
 8        public enum Unit
 9        {
 10            PERCENT,
 11            PIXELS
 12        }
 13
 14        public float value;
 15        public Unit type;
 16
 17        public void SetPixels(float value)
 18        {
 019            this.type = Unit.PIXELS;
 020            this.value = value;
 021        }
 22
 23        public void SetPercent(float value)
 24        {
 025            this.type = Unit.PERCENT;
 026            this.value = value;
 027        }
 28
 29        public UIValue(float value, Unit unitType = Unit.PIXELS)
 30        {
 275231            this.value = value;
 275232            this.type = unitType;
 275233        }
 34
 35        public float GetScaledValue(float parentSize)
 36        {
 102437            if (type == Unit.PIXELS)
 92538                return value;
 39
 40            // Prevent division by zero
 9941            if (parentSize <= Mathf.Epsilon)
 042                parentSize = 1;
 43
 9944            return value / 100 * parentSize;
 45        }
 46    }
 47}