< Summary

Class:NFTShape_Tests
Assembly:LoadableShapesTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/Tests/NFTShape_Tests.cs
Covered lines:21
Uncovered lines:26
Coverable lines:47
Total lines:112
Line coverage:44.6% (21 of 47)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ShapeUpdate()0%440100%
MissingValuesGetDefaultedOnUpdate()0%440100%
CollisionProperty()0%42600%
VisibleProperty()0%42600%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/Tests/NFTShape_Tests.cs

#LineLine coverage
 1using DCL.Components;
 2using DCL.Helpers;
 3using DCL.Models;
 4using NUnit.Framework;
 5using System.Collections;
 6using UnityEngine;
 7using UnityEngine.TestTools;
 8
 9public class NFTShape_Tests : IntegrationTestSuite_Legacy
 10{
 11
 12    [UnityTest]
 13    public IEnumerator ShapeUpdate()
 14    {
 15
 16
 117        string entityId = "1";
 118        TestHelpers.CreateSceneEntity(scene, entityId);
 19
 120        var entity = scene.entities[entityId];
 121        Assert.IsTrue(entity.meshRootGameObject == null, "entity mesh object should be null as the NFTShape hasn't been 
 22
 123        var componentModel = new NFTShape.Model()
 24        {
 25            src = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536"
 26        };
 27
 128        NFTShape component = TestHelpers.SharedComponentCreate<NFTShape, NFTShape.Model>(scene, CLASS_ID.NFT_SHAPE, comp
 129        yield return component.routine;
 30
 131        TestHelpers.SharedComponentAttach(component, entity);
 32
 133        Assert.IsTrue(entity.meshRootGameObject != null, "entity mesh object should already exist as the NFTShape alread
 34
 135        var nftShape = LoadableShape.GetLoaderForEntity(entity) as LoadWrapper_NFT;
 36
 137        var backgroundMaterial = nftShape.loaderController.backgroundMaterial;
 38
 139        Assert.IsTrue(backgroundMaterial.GetColor("_BaseColor") == new Color(0.6404918f, 0.611472f, 0.8584906f), "The NF
 40
 41        // Update color and check if it changed
 142        componentModel.color = Color.yellow;
 143        yield return TestHelpers.SharedComponentUpdate(component, componentModel);
 44
 145        Assert.AreEqual(Color.yellow, backgroundMaterial.GetColor("_BaseColor"), "The NFT frame background color should 
 146    }
 47
 48    [UnityTest]
 49    public IEnumerator MissingValuesGetDefaultedOnUpdate()
 50    {
 51
 52
 153        var component = TestHelpers.SharedComponentCreate<NFTShape, NFTShape.Model>(scene, CLASS_ID.NFT_SHAPE);
 154        yield return component.routine;
 55
 156        Assert.IsFalse(component == null);
 57
 158        yield return TestHelpers.TestSharedComponentDefaultsOnUpdate<NFTShape.Model, NFTShape>(scene, CLASS_ID.NFT_SHAPE
 159    }
 60
 61    [UnityTest]
 62    [Explicit]
 63    [Category("Explicit")]
 64    public IEnumerator CollisionProperty()
 65    {
 66
 67
 068        string entityId = "entityId";
 069        TestHelpers.CreateSceneEntity(scene, entityId);
 070        var entity = scene.entities[entityId];
 071        yield return null;
 72
 73        // Create shape component
 074        var shapeModel = new LoadableShape<LoadWrapper_NFT, NFTShape.Model>.Model();
 075        shapeModel.src = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536";
 76
 077        var shapeComponent = TestHelpers.SharedComponentCreate<LoadableShape<LoadWrapper_NFT, NFTShape.Model>, LoadableS
 078        yield return shapeComponent.routine;
 79
 080        TestHelpers.SharedComponentAttach(shapeComponent, entity);
 81
 082        var shapeLoader = entity.gameObject.GetComponentInChildren<LoadWrapper_NFT>(true);
 083        yield return new WaitUntil(() => shapeLoader.alreadyLoaded);
 84
 085        yield return TestHelpers.TestShapeCollision(shapeComponent, shapeModel, entity);
 086    }
 87
 88    [UnityTest]
 89    [Explicit]
 90    [Category("Explicit")]
 91    public IEnumerator VisibleProperty()
 92    {
 093        string entityId = "entityId";
 094        TestHelpers.CreateSceneEntity(scene, entityId);
 095        var entity = scene.entities[entityId];
 096        yield return null;
 97
 98        // Create shape component
 099        var shapeModel = new LoadableShape<LoadWrapper_NFT, NFTShape.Model>.Model();
 0100        shapeModel.src = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536";
 101
 0102        var shapeComponent = TestHelpers.SharedComponentCreate<LoadableShape<LoadWrapper_NFT, NFTShape.Model>, LoadableS
 0103        yield return shapeComponent.routine;
 104
 0105        TestHelpers.SharedComponentAttach(shapeComponent, entity);
 106
 0107        var shapeLoader = entity.gameObject.GetComponentInChildren<LoadWrapper_NFT>(true);
 0108        yield return new WaitUntil(() => shapeLoader.alreadyLoaded);
 109
 0110        yield return TestHelpers.TestShapeVisibility(shapeComponent, shapeModel, entity);
 0111    }
 112}