< Summary

Class:NFTSkinFactory
Assembly:AvatarEditorHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AvatarEditorHUD/Scripts/NFTSkinFactory.cs
Covered lines:12
Uncovered lines:1
Coverable lines:13
Total lines:48
Line coverage:92.3% (12 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
EnsureNFTDictionary()0%440100%
GetSkinForRarity(...)0%3.043083.33%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5public class NFTSkinFactory : ScriptableObject
 6{
 7    [System.Serializable]
 8    public class NftMap
 9    {
 10        public string rarity;
 11        public NFTItemToggleSkin skin;
 12    }
 13
 14    public NftMap[] nftList;
 15
 16    internal Dictionary<string, NftMap> nftDictionary;
 17
 18    public void EnsureNFTDictionary()
 19    {
 365420        if (nftDictionary == null)
 21        {
 122            nftDictionary = new Dictionary<string, NftMap>();
 23
 1824            for (int i = 0; i < nftList.Length; i++)
 25            {
 826                NftMap nftMap = nftList[i];
 27
 828                if (!nftDictionary.ContainsKey(nftMap.rarity))
 29                {
 830                    nftDictionary.Add(nftMap.rarity, nftMap);
 31                }
 32            }
 33        }
 365434    }
 35
 36    public NFTItemToggleSkin GetSkinForRarity(string rarity)
 37    {
 365438        EnsureNFTDictionary();
 39
 365440        if (string.IsNullOrEmpty(rarity))
 361241            return nftDictionary["base"].skin;
 42
 4243        if (!nftDictionary.ContainsKey(rarity))
 044            return nftDictionary["base"].skin;
 45
 4246        return nftDictionary[rarity].skin;
 47    }
 48}