< Summary

Class:DCL.Builder.SearchInfo
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/SectionController/SearchInfo/SearchInfo.cs
Covered lines:15
Uncovered lines:8
Coverable lines:23
Total lines:78
Line coverage:65.2% (15 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<DCL.Builder.ISearchInfo>.Compare(...)0%13.786040%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/SectionController/SearchInfo/SearchInfo.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4namespace DCL.Builder
 5{
 6    public interface ISearchInfo : ISearchable, ISortable<ISearchInfo>
 7    {
 8        string id { get; }
 9        string name { get; }
 10        int size { get; }
 11        bool isOwner { get; }
 12        bool isOperator { get; }
 13        bool isContributor { get; }
 14        void SetId(string id);
 15        void SetName(string name);
 16        void SetSize(int size);
 17        void SetCoords(string coords);
 18        void SetRole(bool isOwner);
 19    }
 20
 21    internal class SearchInfo : ISearchInfo
 22    {
 1623        string ISearchInfo.id => id;
 124        string ISearchInfo.name => name;
 925        int ISearchInfo.size => size;
 026        bool ISearchInfo.isOwner => isOwner;
 027        bool ISearchInfo.isOperator => isOperator;
 028        bool ISearchInfo.isContributor => isContributor;
 029        string[] ISearchable.keywords => keywords;
 30
 31        private bool isOwner;
 32        private bool isOperator;
 33        private bool isContributor;
 34        internal string id;
 35        private string name;
 36        private int size;
 37        private string[] keywords;
 38
 039        public SearchInfo() { keywords = new string[2]; }
 40
 7441        void ISearchInfo.SetId(string id) { this.id = id; }
 42
 43        void ISearchInfo.SetName(string name)
 44        {
 3845            this.name = name;
 3846            keywords[0] = name;
 3847        }
 48
 7449        void ISearchInfo.SetSize(int size) { this.size = size; }
 50
 6051        void ISearchInfo.SetCoords(string coords) { keywords[1] = coords; }
 52
 53        void ISearchInfo.SetRole(bool isOwner)
 54        {
 3255            this.isOwner = isOwner;
 3256            this.isOperator = !isOwner;
 3257            this.isContributor = false;
 3258        }
 59
 60        int ISortable<ISearchInfo>.Compare(string sortType, bool isDescendingOrder, ISearchInfo other)
 61        {
 62            switch (sortType)
 63            {
 64                case SectionSearchHandler.NAME_SORT_TYPE_ASC:
 165                    return String.CompareOrdinal(name.ToLower(), other.name.ToLower());
 66                case SectionSearchHandler.NAME_SORT_TYPE_DESC:
 067                    return String.CompareOrdinal(other.name.ToLower(), name.ToLower());
 68                case SectionSearchHandler.SIZE_SORT_TYPE_DESC:
 069                    return other.size - size;
 70                case SectionSearchHandler.SIZE_SORT_TYPE_ASC:
 971                    return size - other.size;
 72                default:
 073                    return 0;
 74            }
 75        }
 76    }
 77
 78}