< Summary

Class:BuilderInWorldTestHelper
Assembly:BuilderInWorldTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/Tests/Helpers/BuilderInWorldTestHelper.cs
Covered lines:41
Uncovered lines:0
Coverable lines:41
Total lines:91
Line coverage:100% (41 of 41)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreateSmartItemEntity(...)0%220100%
CreateCatalogItemAdapter(...)0%110100%
CreateTestCatalogLocalMultipleFloorObjects()0%220100%
CreateTestCatalogLocalSingleObject()0%220100%
CreateTestSmartItemCatalogLocalSingleObject()0%220100%
CreateNFT()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/Tests/Helpers/BuilderInWorldTestHelper.cs

#LineLine coverage
 1using DCL.Helpers;
 2using DCL.Helpers.NFT;
 3using System.Collections;
 4using System.Collections.Generic;
 5using System.IO;
 6using System.Runtime.Serialization.Formatters.Binary;
 7using DCL.Components;
 8using DCL.Controllers;
 9using DCL.Models;
 10using UnityEngine;
 11using UnityEngine.UI;
 12
 13public static class BuilderInWorldTestHelper
 14{
 15    public static DCLBuilderInWorldEntity CreateSmartItemEntity(BuilderInWorldEntityHandler entityHandler, ParcelScene s
 16    {
 117        if (model == null)
 118            model = new SmartItemComponent.Model();
 19
 120        DCLBuilderInWorldEntity entity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero);
 21
 122        scene.EntityComponentCreateOrUpdateWithModel(entity.rootEntity.entityId, CLASS_ID_COMPONENT.SMART_ITEM, model);
 23
 124        return entity;
 25    }
 26
 27    public static CatalogItemAdapter CreateCatalogItemAdapter(GameObject gameObject)
 28    {
 129        CatalogItemAdapter adapter = Utils.GetOrCreateComponent<CatalogItemAdapter>(gameObject);
 130        adapter.onFavoriteColor = Color.white;
 131        adapter.offFavoriteColor = Color.white;
 132        adapter.favImg = Utils.GetOrCreateComponent<Image>(gameObject);
 133        adapter.smartItemGO = gameObject;
 134        adapter.lockedGO = gameObject;
 135        adapter.canvasGroup = Utils.GetOrCreateComponent<CanvasGroup>(gameObject);
 36
 137        GameObject newGameObject = new GameObject();
 138        newGameObject.transform.SetParent(gameObject.transform);
 139        adapter.thumbnailImg = Utils.GetOrCreateComponent<RawImage>(newGameObject);
 140        return adapter;
 41    }
 42
 43    public static void CreateTestCatalogLocalMultipleFloorObjects()
 44    {
 445        AssetCatalogBridge.i.ClearCatalog();
 446        string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/multipleSceneObjectsCatalog.json";
 47
 448        if (File.Exists(jsonPath))
 49        {
 450            string jsonValue = File.ReadAllText(jsonPath);
 451            AssetCatalogBridge.i.AddFullSceneObjectCatalog(jsonValue);
 52        }
 453    }
 54
 55    public static void CreateTestCatalogLocalSingleObject()
 56    {
 1757        AssetCatalogBridge.i.ClearCatalog();
 1758        string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/sceneObjectCatalog.json";
 59
 1760        if (File.Exists(jsonPath))
 61        {
 1762            string jsonValue = File.ReadAllText(jsonPath);
 1763            AssetCatalogBridge.i.AddFullSceneObjectCatalog(jsonValue);
 64        }
 1765    }
 66
 67    public static void CreateTestSmartItemCatalogLocalSingleObject()
 68    {
 169        AssetCatalogBridge.i.ClearCatalog();
 170        string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/smartItemSceneObjectCatalog.json";
 71
 172        if (File.Exists(jsonPath))
 73        {
 174            string jsonValue = File.ReadAllText(jsonPath);
 175            AssetCatalogBridge.i.AddFullSceneObjectCatalog(jsonValue);
 76        }
 177    }
 78
 79    public static void CreateNFT()
 80    {
 381        string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/nftAsset.json";
 82
 383        if (File.Exists(jsonPath))
 84        {
 385            string jsonValue = File.ReadAllText(jsonPath);
 386            NFTOwner owner = NFTOwner.defaultNFTOwner;
 387            owner.assets.Add(JsonUtility.FromJson<NFTInfo>(jsonValue));
 388            BuilderInWorldNFTController.i.NftsFeteched(owner);
 89        }
 390    }
 91}