< Summary

Class:DCL.Builder.SectionSearchHandler
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/SectionController/SearchInfo/SectionSearchHandler.cs
Covered lines:15
Uncovered lines:18
Coverable lines:33
Total lines:75
Line coverage:45.4% (15 of 33)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SectionSearchHandler()0%110100%
get_sortTypes()0%2100%
get_searchString()0%2100%
get_filterOwner()0%2100%
get_filterOperator()0%2100%
get_filterContributor()0%2100%
get_sortType()0%2100%
get_resultCount()0%2100%
SetSearchableList(...)0%110100%
AddItem(...)0%2100%
RemoveItem(...)0%2100%
SetFilter(...)0%2100%
SetSortType(...)0%110100%
SetSearchString(...)0%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace DCL.Builder
 5{
 6    internal class SectionSearchHandler : ISectionSearchHandler
 7    {
 8        public const string NAME_SORT_TYPE_ASC = "Alphabetic A-Z";
 9        public const string NAME_SORT_TYPE_DESC = "Alphabetic Z-A";
 10        public const string SIZE_SORT_TYPE_ASC = "Size Asc";
 11        public const string SIZE_SORT_TYPE_DESC = "Size Desc";
 12
 1113        private readonly string[] scenesSortTypes =
 14        {
 15            NAME_SORT_TYPE_ASC, NAME_SORT_TYPE_DESC,
 16            SIZE_SORT_TYPE_ASC, SIZE_SORT_TYPE_DESC
 17        };
 18
 19        public event Action OnUpdated;
 20        public event Action<List<ISearchInfo>> OnResult;
 21
 22        private readonly SearchHandler<ISearchInfo> scenesSearchHandler;
 23
 24        private bool filterOwner = false;
 25        private bool filterOperator = false;
 26        private bool filterContributor = false;
 27
 028        string[] ISectionSearchHandler.sortTypes => scenesSortTypes;
 029        string ISectionSearchHandler.searchString => scenesSearchHandler.currentSearchString;
 030        bool ISectionSearchHandler.filterOwner => filterOwner;
 031        bool ISectionSearchHandler.filterOperator => filterOperator;
 032        bool ISectionSearchHandler.filterContributor => filterContributor;
 033        string ISectionSearchHandler.sortType => scenesSearchHandler.currentSortingType;
 034        int ISectionSearchHandler.resultCount => scenesSearchHandler.resultCount;
 35
 1136        public SectionSearchHandler()
 37        {
 1138            scenesSearchHandler = new SearchHandler<ISearchInfo>(scenesSortTypes, (item) =>
 39            {
 2040                bool result = true;
 2041                if (filterContributor)
 042                    result = item.isContributor;
 2043                if (filterOperator && result)
 044                    result = item.isOperator;
 2045                if (filterOwner && result)
 046                    result = item.isOwner;
 2047                return result;
 48            });
 49
 1150            scenesSearchHandler.OnSearchChanged += list =>
 51            {
 1352                OnUpdated?.Invoke();
 1353                OnResult?.Invoke(list);
 1254            };
 1155        }
 56
 2457        void ISectionSearchHandler.SetSearchableList(List<ISearchInfo> list) { scenesSearchHandler.SetSearchableList(lis
 58
 059        void ISectionSearchHandler.AddItem(ISearchInfo item) { scenesSearchHandler.AddItem(item); }
 60
 061        void ISectionSearchHandler.RemoveItem(ISearchInfo item) { scenesSearchHandler.RemoveItem(item); }
 62
 63        void ISectionSearchHandler.SetFilter(bool isOwner, bool isOperator, bool isContributor)
 64        {
 065            filterOwner = isOwner;
 066            filterOperator = isOperator;
 067            filterContributor = isContributor;
 068            scenesSearchHandler.NotifyFilterChanged();
 069        }
 70
 271        void ISectionSearchHandler.SetSortType(string sortType) { scenesSearchHandler.NotifySortTypeChanged(sortType); }
 72
 073        void ISectionSearchHandler.SetSearchString(string searchText) { scenesSearchHandler.NotifySearchChanged(searchTe
 74    }
 75}