< Summary

Class:ItemToggleFactory
Assembly:AvatarEditorHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarEditorHUD/Scripts/ItemToggleFactory.cs
Covered lines:12
Uncovered lines:4
Coverable lines:16
Total lines:58
Line coverage:75% (12 of 16)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
EnsureNFTDictionary()0%440100%
CreateBaseWearable(...)0%220100%
CreateItemToggleFromRarity(...)0%64050%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarEditorHUD/Scripts/ItemToggleFactory.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using UnityEngine;
 3
 4public class ItemToggleFactory : ScriptableObject
 5{
 6    [System.Serializable]
 7    public class NftMap
 8    {
 9        public string rarity;
 10        public ItemToggle prefab;
 11    }
 12
 13    public ItemToggle baseWearable;
 14    public NftMap[] nftList;
 15
 16    internal Dictionary<string, NftMap> nftDictionary;
 17
 18    public void EnsureNFTDictionary()
 19    {
 3220        if (nftDictionary == null)
 21        {
 122            nftDictionary = new Dictionary<string, NftMap>();
 23
 1624            for (int i = 0; i < nftList.Length; i++)
 25            {
 726                NftMap nftMap = nftList[i];
 27
 728                if (!nftDictionary.ContainsKey(nftMap.rarity))
 29                {
 730                    nftDictionary.Add(nftMap.rarity, nftMap);
 31                }
 32            }
 33        }
 3234    }
 35
 386436    public ItemToggle CreateBaseWearable(Transform parent = null) { return parent == null ? Instantiate(baseWearable) : 
 37
 38    public ItemToggle CreateItemToggleFromRarity(string rarity, Transform parent = null)
 39    {
 3240        EnsureNFTDictionary();
 41
 3242        if (!nftDictionary.ContainsKey(rarity))
 43        {
 44#if UNITY_EDITOR
 045            Debug.LogError("Item toggle of rarity " + rarity + " can't be instantiated because it does not exist in the 
 46#endif
 047            return CreateBaseWearable(parent);
 48        }
 49
 3250        if (nftDictionary[rarity].prefab == null)
 51        {
 052            Debug.LogError("Prefab for rarity " + rarity + " is null!");
 053            return CreateBaseWearable(parent);
 54        }
 55
 3256        return parent == null ? Instantiate(nftDictionary[rarity].prefab) : Instantiate(nftDictionary[rarity].prefab, pa
 57    }
 58}