< Summary

Class: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:72
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
 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
 1111    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
 026    string[] ISectionSearchHandler.sortTypes => scenesSortTypes;
 027    string ISectionSearchHandler.searchString => scenesSearchHandler.currentSearchString;
 028    bool ISectionSearchHandler.filterOwner => filterOwner;
 029    bool ISectionSearchHandler.filterOperator => filterOperator;
 030    bool ISectionSearchHandler.filterContributor => filterContributor;
 031    string ISectionSearchHandler.sortType => scenesSearchHandler.currentSortingType;
 032    int ISectionSearchHandler.resultCount => scenesSearchHandler.resultCount;
 33
 1134    public SectionSearchHandler()
 35    {
 1136        scenesSearchHandler = new SearchHandler<ISearchInfo>(scenesSortTypes, (item) =>
 37        {
 2038            bool result = true;
 2039            if (filterContributor)
 040                result = item.isContributor;
 2041            if (filterOperator && result)
 042                result = item.isOperator;
 2043            if (filterOwner && result)
 044                result = item.isOwner;
 2045            return result;
 46        });
 47
 1148        scenesSearchHandler.OnSearchChanged += list =>
 49        {
 1350            OnUpdated?.Invoke();
 1351            OnResult?.Invoke(list);
 1252        };
 1153    }
 54
 2455    void ISectionSearchHandler.SetSearchableList(List<ISearchInfo> list) { scenesSearchHandler.SetSearchableList(list); 
 56
 057    void ISectionSearchHandler.AddItem(ISearchInfo item) { scenesSearchHandler.AddItem(item); }
 58
 059    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
 269    void ISectionSearchHandler.SetSortType(string sortType) { scenesSearchHandler.NotifySortTypeChanged(sortType); }
 70
 071    void ISectionSearchHandler.SetSearchString(string searchText) { scenesSearchHandler.NotifySearchChanged(searchText);
 72}