< Summary

Class:SearchInfo
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/SectionController/SearchInfo/SearchInfo.cs
Covered lines:16
Uncovered lines:7
Coverable lines:23
Total lines:74
Line coverage:69.5% (16 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
get_id()0%110100%
get_name()0%110100%
get_size()0%110100%
get_isOwner()0%2100%
get_isOperator()0%2100%
get_isContributor()0%2100%
get_keywords()0%2100%
SearchInfo()0%2100%
SetId(...)0%110100%
SetName(...)0%110100%
SetSize(...)0%110100%
SetCoords(...)0%110100%
SetRole(...)0%110100%
ISortable<ISearchInfo>.Compare(...)0%8.36060%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/SectionController/SearchInfo/SearchInfo.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4internal interface ISearchInfo : ISearchable, ISortable<ISearchInfo>
 5{
 6    string id { get; }
 7    string name { get; }
 8    int size { get; }
 9    bool isOwner { get; }
 10    bool isOperator { get; }
 11    bool isContributor { get; }
 12    void SetId(string id);
 13    void SetName(string name);
 14    void SetSize(int size);
 15    void SetCoords(string coords);
 16    void SetRole(bool isOwner);
 17}
 18
 19internal class SearchInfo : ISearchInfo
 20{
 6621    string ISearchInfo.id => id;
 822    string ISearchInfo.name => name;
 5423    int ISearchInfo.size => size;
 024    bool ISearchInfo.isOwner => isOwner;
 025    bool ISearchInfo.isOperator => isOperator;
 026    bool ISearchInfo.isContributor => isContributor;
 027    string[] ISearchable.keywords => keywords;
 28
 29    private bool isOwner;
 30    private bool isOperator;
 31    private bool isContributor;
 32    private string id;
 33    private string name;
 34    private int size;
 35    private string[] keywords;
 36
 037    public SearchInfo() { keywords = new string[2]; }
 38
 11239    void ISearchInfo.SetId(string id) { this.id = id; }
 40
 41    void ISearchInfo.SetName(string name)
 42    {
 5743        this.name = name;
 5744        keywords[0] = name;
 5745    }
 46
 11647    void ISearchInfo.SetSize(int size) { this.size = size; }
 48
 11249    void ISearchInfo.SetCoords(string coords) { keywords[1] = coords; }
 50
 51    void ISearchInfo.SetRole(bool isOwner)
 52    {
 5853        this.isOwner = isOwner;
 5854        this.isOperator = !isOwner;
 5855        this.isContributor = false;
 5856    }
 57
 58    int ISortable<ISearchInfo>.Compare(string sortType, bool isDescendingOrder, ISearchInfo other)
 59    {
 60        switch (sortType)
 61        {
 62            case SectionSearchHandler.NAME_SORT_TYPE_ASC:
 863                return String.CompareOrdinal(name, other.name);
 64            case SectionSearchHandler.NAME_SORT_TYPE_DESC:
 065                return String.CompareOrdinal(other.name, name);
 66            case SectionSearchHandler.SIZE_SORT_TYPE_DESC:
 4567                return other.size - size;
 68            case SectionSearchHandler.SIZE_SORT_TYPE_ASC:
 969                return size - other.size;
 70            default:
 071                return 0;
 72        }
 73    }
 74}