< Summary

Class:DCL.EmotesWheel.EmoteWheelSlot
Assembly:EmotesWheelHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/EmotesWheelHUD/EmoteWheelSlot.cs
Covered lines:14
Uncovered lines:8
Coverable lines:22
Total lines:61
Line coverage:63.6% (14 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetId(...)0%110100%
SetName(...)0%110100%
SetRarity(...)0%110100%
SetImage(...)0%2.52050%
SetImage(...)0%6200%
SetAsLoading(...)0%110100%
OnPointerEnter(...)0%6200%
OnPointerExit(...)0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/EmotesWheelHUD/EmoteWheelSlot.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4using UnityEngine.UI;
 5
 6namespace DCL.EmotesWheel
 7{
 8    public class EmoteWheelSlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
 9    {
 10        [SerializeField] internal Button_OnPointerDown button;
 11        [SerializeField] internal ImageComponentView image;
 12        [SerializeField] internal Image rarityImage;
 13        [SerializeField] internal GameObject loadingSpinnerGO;
 14        [SerializeField] internal Sprite defaultImage;
 15
 16        public event Action<string> onSlotHover;
 17
 6018        public string emoteId { get; private set; }
 3019        public bool isLoading { get; private set; }
 20
 21        private string emoteName;
 22
 6023        public void SetId(string id) { emoteId = id; }
 24
 6025        public void SetName(string name) { emoteName = name; }
 26
 27        public void SetRarity(bool isActive, Color color)
 28        {
 3029            rarityImage.transform.parent.gameObject.SetActive(isActive);
 3030            rarityImage.color = color;
 3031        }
 32
 33        public void SetImage(Sprite sprite)
 34        {
 3035            if (sprite != null)
 3036                image.SetImage(sprite);
 37            else
 038                image.SetImage(sprite);
 039        }
 40
 41        public void SetImage(string uri)
 42        {
 043            if (!string.IsNullOrEmpty(uri))
 044                image.SetImage(uri);
 45            else
 046                image.SetImage(defaultImage);
 047        }
 48
 49        public void SetAsLoading(bool isLoading)
 50        {
 3051            this.isLoading = isLoading;
 3052            loadingSpinnerGO.SetActive(isLoading);
 3053            image.gameObject.SetActive(!isLoading);
 3054            button.enabled = !isLoading;
 3055        }
 56
 057        public void OnPointerEnter(PointerEventData eventData) { onSlotHover?.Invoke(emoteName); }
 58
 059        public void OnPointerExit(PointerEventData eventData) { onSlotHover?.Invoke(string.Empty); }
 60    }
 61}