< Summary

Class:FavoritesController
Assembly:BuilderInWorldCatalog
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/Catalog/Favorites/FavoritesController.cs
Covered lines:17
Uncovered lines:2
Coverable lines:19
Total lines:41
Line coverage:89.4% (17 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
FavoritesController(...)0%220100%
Dispose()0%2.152066.67%
GetFavorites()0%2100%
ToggleFavoriteState(...)0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/Catalog/Favorites/FavoritesController.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3public class FavoritesController
 4{
 585    private List<CatalogItem> favoritesCatalogItems = new List<CatalogItem>();
 6
 7    public CatalogGroupListView catalogGroupListView;
 8
 589    public FavoritesController(CatalogGroupListView catalogGroupListView)
 10    {
 5811        if (catalogGroupListView == null)
 3012            return;
 13
 2814        catalogGroupListView.OnCatalogItemFavorite += ToggleFavoriteState;
 2815    }
 16
 17    public void Dispose()
 18    {
 5619        if (catalogGroupListView != null)
 020            catalogGroupListView.OnCatalogItemFavorite -= ToggleFavoriteState;
 5621    }
 22
 023    public List<CatalogItem> GetFavorites() { return favoritesCatalogItems; }
 24
 25    public void ToggleFavoriteState(CatalogItem catalogItem, CatalogItemAdapter adapter)
 26    {
 227        if (!favoritesCatalogItems.Contains(catalogItem))
 28        {
 129            favoritesCatalogItems.Add(catalogItem);
 130            catalogItem.SetFavorite(true);
 131            BIWAnalytics.FavoriteAdded(catalogItem);
 132        }
 33        else
 34        {
 135            favoritesCatalogItems.Remove(catalogItem);
 136            catalogItem.SetFavorite(false);
 37        }
 38
 239        adapter?.SetFavorite(catalogItem.IsFavorite());
 240    }
 41}