< Summary

Class:SearchRecordComponentView
Assembly:Navmap
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/SearchRecordComponentView.cs
Covered lines:24
Uncovered lines:5
Coverable lines:29
Total lines:76
Line coverage:82.7% (24 of 29)
Covered branches:0
Total branches:0
Covered methods:6
Total methods:7
Method coverage:85.7% (6 of 7)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnSelectedRecord()0%20400%
RefreshControl()0%2.012085.71%
SetRecordText(...)0%110100%
SetIcon(...)0%110100%
SetPlayerCount(...)0%110100%
SetCoordinates(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/SearchRecordComponentView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using System;
 3using TMPro;
 4using UIComponents.Scripts.Components;
 5using UnityEngine;
 6using UnityEngine.UI;
 7
 8public class SearchRecordComponentView : BaseComponentView<SearchRecordComponentModel>, ISearchRecordComponentView
 9{
 10    [SerializeField] internal TMP_Text recordText;
 11    [SerializeField] internal TMP_Text recordTextNoPlayerCount;
 12    [SerializeField] internal GameObject historyIcon;
 13    [SerializeField] private Button recordButton;
 14    [SerializeField] internal GameObject playerCountParent;
 15    [SerializeField] internal TMP_Text playerCount;
 16
 17    public event Action<string> OnSelectedHistoryRecord;
 18    public event Action<Vector2Int> OnSelectedRegularRecord;
 19
 20    public override void Awake()
 21    {
 922        base.Awake();
 23
 924        recordButton.onClick.RemoveAllListeners();
 925        recordButton.onClick.AddListener(OnSelectedRecord);
 926    }
 27
 28    public void OnSelectedRecord()
 29    {
 030        if (model.isHistory)
 31        {
 032            OnSelectedHistoryRecord?.Invoke(model.recordText);
 33        }
 34        else
 35        {
 036            OnSelectedRegularRecord?.Invoke(model.placeCoordinates);
 37        }
 038    }
 39
 40    public override void RefreshControl()
 41    {
 542        if (model == null)
 043            return;
 44
 545        SetRecordText(model.recordText);
 546        SetIcon(model.isHistory);
 547        SetPlayerCount(model.playerCount);
 548        SetCoordinates(model.placeCoordinates);
 549    }
 50
 51    public void SetRecordText(string text)
 52    {
 653        model.recordText = text;
 654        recordText.text = text;
 655        recordTextNoPlayerCount.text = text;
 656    }
 57
 58    public void SetIcon(bool isHistory)
 59    {
 660        model.isHistory = isHistory;
 661        historyIcon.SetActive(isHistory);
 662    }
 63
 64    public void SetPlayerCount(int count)
 65    {
 766        playerCountParent.SetActive(count > 0);
 767        recordText.gameObject.SetActive(count > 0);
 768        recordTextNoPlayerCount.gameObject.SetActive(count == 0);
 769        playerCount.text = count.ToString();
 770    }
 71
 72    public void SetCoordinates(Vector2Int coordinates)
 73    {
 574        model.placeCoordinates = coordinates;
 575    }
 76}