< Summary

Class:DCL.AssetLibrary_Mock
Assembly:AssetPromiseKeeper
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/Common/Mock/AssetLibrary_Mock.cs
Covered lines:18
Uncovered lines:2
Coverable lines:20
Total lines:65
Line coverage:90% (18 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AssetLibrary_Mock()0%110100%
Add(...)0%220100%
Contains(...)0%330100%
Contains(...)0%330100%
Get(...)0%2.062075%
Release(...)0%330100%
Cleanup()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/Common/Mock/AssetLibrary_Mock.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace DCL
 5{
 6    public class AssetLibrary_Mock : AssetLibrary<Asset_Mock>
 7    {
 8        public class RefCountedMockAsset
 9        {
 10            public Asset_Mock asset;
 11            public int referenceCount;
 12        }
 13
 1314        public Dictionary<object, RefCountedMockAsset> masterAssets = new Dictionary<object, RefCountedMockAsset>();
 15
 16        public override bool Add(Asset_Mock asset)
 17        {
 1018            if (!masterAssets.ContainsKey(asset.id))
 1019                masterAssets.Add(asset.id, new RefCountedMockAsset() { referenceCount = 0, asset = asset });
 20
 1021            return true;
 22        }
 23
 24        public override bool Contains(object id)
 25        {
 15626            if (masterAssets == null || id == null)
 127                return false;
 28
 15529            return masterAssets.ContainsKey(id);
 30        }
 31
 32        public override bool Contains(Asset_Mock asset)
 33        {
 1634            if (masterAssets == null || asset == null)
 235                return false;
 36
 1437            return masterAssets.ContainsKey(asset.id);
 38        }
 39
 40        public override Asset_Mock Get(object id)
 41        {
 6042            if (Contains(id))
 43            {
 6044                masterAssets[id].referenceCount++;
 6045                return masterAssets[id].asset.Clone() as Asset_Mock;
 46            }
 47
 048            return null;
 49        }
 50
 51        public override void Release(Asset_Mock asset)
 52        {
 553            if (Contains(asset.id))
 54            {
 555                masterAssets[asset.id].referenceCount--;
 556                if (masterAssets[asset.id].referenceCount <= 0)
 57                {
 258                    masterAssets.Remove(asset.id);
 59                }
 60            }
 561        }
 62
 063        public override void Cleanup() { throw new NotImplementedException(); }
 64    }
 65}