< Summary

Class:FavoritesController
Assembly:BuilderInWorldCatalog
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/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/DCLPlugins/BuilderInWorld/Scripts/Catalog/Favorites/FavoritesController.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3public class FavoritesController
 4{
 325    private List<CatalogItem> favoritesCatalogItems = new List<CatalogItem>();
 6
 7    public CatalogGroupListView catalogGroupListView;
 8
 329    public FavoritesController(CatalogGroupListView catalogGroupListView)
 10    {
 3211        if (catalogGroupListView == null)
 3012            return;
 13
 214        catalogGroupListView.OnCatalogItemFavorite += ToggleFavoriteState;
 215    }
 16
 17    public void Dispose()
 18    {
 3019        if (catalogGroupListView != null)
 020            catalogGroupListView.OnCatalogItemFavorite -= ToggleFavoriteState;
 3021    }
 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}