< Summary

Class:SectionSearchHandler
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/SectionController/SearchInfo/SectionSearchHandler.cs
Covered lines:24
Uncovered lines:9
Coverable lines:33
Total lines:72
Line coverage:72.7% (24 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%110100%
get_searchString()0%110100%
get_filterOwner()0%110100%
get_filterOperator()0%110100%
get_filterContributor()0%110100%
get_sortType()0%110100%
get_resultCount()0%110100%
SetSearchableList(...)0%110100%
AddItem(...)0%110100%
RemoveItem(...)0%110100%
SetFilter(...)0%2100%
SetSortType(...)0%110100%
SetSearchString(...)0%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4internal class SectionSearchHandler : ISectionSearchHandler
 5{
 6    public const string NAME_SORT_TYPE_ASC = "Alphabetic A-Z";
 7    public const string NAME_SORT_TYPE_DESC = "Alphabetic Z-A";
 8    public const string SIZE_SORT_TYPE_ASC = "Size Asc";
 9    public const string SIZE_SORT_TYPE_DESC = "Size Desc";
 10
 1211    private readonly string[] scenesSortTypes =
 12    {
 13        NAME_SORT_TYPE_ASC, NAME_SORT_TYPE_DESC,
 14        SIZE_SORT_TYPE_ASC, SIZE_SORT_TYPE_DESC
 15    };
 16
 17    public event Action OnUpdated;
 18    public event Action<List<ISearchInfo>> OnResult;
 19
 20    private readonly SearchHandler<ISearchInfo> scenesSearchHandler;
 21
 22    private bool filterOwner = false;
 23    private bool filterOperator = false;
 24    private bool filterContributor = false;
 25
 126    string[] ISectionSearchHandler.sortTypes => scenesSortTypes;
 127    string ISectionSearchHandler.searchString => scenesSearchHandler.currentSearchString;
 228    bool ISectionSearchHandler.filterOwner => filterOwner;
 229    bool ISectionSearchHandler.filterOperator => filterOperator;
 230    bool ISectionSearchHandler.filterContributor => filterContributor;
 131    string ISectionSearchHandler.sortType => scenesSearchHandler.currentSortingType;
 132    int ISectionSearchHandler.resultCount => scenesSearchHandler.resultCount;
 33
 1234    public SectionSearchHandler()
 35    {
 1236        scenesSearchHandler = new SearchHandler<ISearchInfo>(scenesSortTypes, (item) =>
 37        {
 3538            bool result = true;
 3539            if (filterContributor)
 040                result = item.isContributor;
 3541            if (filterOperator && result)
 042                result = item.isOperator;
 3543            if (filterOwner && result)
 044                result = item.isOwner;
 3545            return result;
 46        });
 47
 1248        scenesSearchHandler.OnSearchChanged += list =>
 49        {
 3250            OnUpdated?.Invoke();
 3251            OnResult?.Invoke(list);
 3252        };
 1253    }
 54
 4655    void ISectionSearchHandler.SetSearchableList(List<ISearchInfo> list) { scenesSearchHandler.SetSearchableList(list); 
 56
 257    void ISectionSearchHandler.AddItem(ISearchInfo item) { scenesSearchHandler.AddItem(item); }
 58
 1259    void ISectionSearchHandler.RemoveItem(ISearchInfo item) { scenesSearchHandler.RemoveItem(item); }
 60
 61    void ISectionSearchHandler.SetFilter(bool isOwner, bool isOperator, bool isContributor)
 62    {
 063        filterOwner = isOwner;
 064        filterOperator = isOperator;
 065        filterContributor = isContributor;
 066        scenesSearchHandler.NotifyFilterChanged();
 067    }
 68
 469    void ISectionSearchHandler.SetSortType(string sortType) { scenesSearchHandler.NotifySortTypeChanged(sortType); }
 70
 071    void ISectionSearchHandler.SetSearchString(string searchText) { scenesSearchHandler.NotifySearchChanged(searchText);
 72}