< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GroundRaycast()0%220100%
SceneReferences()0%110100%
BuilderInWorldEntityComponents()0%110100%
TearDown()0%330100%

File(s)

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

#LineLine coverage
 1using Builder;
 2using Cinemachine;
 3using DCL;
 4using DCL.Components;
 5using DCL.Configuration;
 6using DCL.Helpers;
 7using DCL.Models;
 8using Newtonsoft.Json;
 9using NUnit.Framework;
 10using System;
 11using System.Collections;
 12using System.Collections.Generic;
 13using UnityEngine;
 14using UnityEngine.TestTools;
 15
 16public class BuilderInWorldShould : IntegrationTestSuite_Legacy
 17{
 18    [Test]
 19    public void GroundRaycast()
 20    {
 21        RaycastHit hit;
 122        BuilderInWorldController builderInWorldController = Resources.FindObjectsOfTypeAll<BuilderInWorldController>()[0
 123        BuilderInWorldGodMode godMode = builderInWorldController.GetComponentInChildren<BuilderInWorldGodMode>(true);
 24
 125        Vector3 fromPosition = new Vector3(0, 10, 0);
 126        Vector3 toPosition = Vector3.zero;
 127        Vector3 direction = toPosition - fromPosition;
 28
 129        bool groundLayerFound = Physics.Raycast(fromPosition, direction, out hit, BuilderInWorldGodMode.RAYCAST_MAX_DIST
 30
 131        UnityEngine.Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
 32
 133        if (Physics.Raycast(ray, out hit, BuilderInWorldGodMode.RAYCAST_MAX_DISTANCE, godMode.groundLayer))
 34        {
 135            groundLayerFound = true;
 36        }
 37
 138        Assert.IsTrue(groundLayerFound, "The ground layer is not set to Ground");
 139    }
 40
 41    [Test]
 42    public void SceneReferences()
 43    {
 144        BuilderInWorldController builderInWorldController = Resources.FindObjectsOfTypeAll<BuilderInWorldController>()[0
 45
 146        Assert.IsNotNull(builderInWorldController.cursorGO, "References on the builder-in-world prefab are null, check t
 147        Assert.IsNotNull(builderInWorldController.inputController, "References on the builder-in-world prefab are null, 
 148        Assert.IsNotNull(builderInWorldController.cameraParentGO, "References on the builder-in-world prefab are null, c
 49
 50
 151        BuilderInWorldGodMode godMode = builderInWorldController.GetComponentInChildren<BuilderInWorldGodMode>();
 52
 153        Assert.IsNotNull(godMode.avatarRenderer, "References on the builder-in-world prefab are null, check them all!");
 154        Assert.IsNotNull(godMode.mouseCatcher, "References on the builder-in-world god mode are null, check them all!");
 155        Assert.IsNotNull(godMode.cameraController, "References on the builder-in-world god mode are null, check them all
 156        Assert.IsNotNull(godMode.freeCameraController, "References on the builder-in-world god mode are null, check them
 57
 158        DCLBuilderRaycast dCLBuilderRaycast = godMode.GetComponentInChildren<DCLBuilderRaycast>();
 59
 160        Assert.IsNotNull(dCLBuilderRaycast.builderCamera, "Camera reference on the builder-in-world god mode children ar
 61
 162        VoxelController voxelController = godMode.GetComponent<VoxelController>();
 63
 164        Assert.IsNotNull(voxelController.freeCameraMovement, "Camera reference on the builder-in-world voxel controller 
 165    }
 66
 67    [Test]
 68    public void BuilderInWorldEntityComponents()
 69    {
 170        string entityId = "1";
 171        TestHelpers.CreateSceneEntity(scene, entityId);
 72
 173        DCLBuilderInWorldEntity biwEntity = Utils.GetOrCreateComponent<DCLBuilderInWorldEntity>(scene.entities[entityId]
 174        biwEntity.Init(scene.entities[entityId], null);
 75
 176        Assert.IsTrue(biwEntity.entityUniqueId == scene.sceneData.id + scene.entities[entityId].entityId, "Entity id is 
 77
 178        SmartItemComponent.Model model = new SmartItemComponent.Model();
 79
 180        scene.EntityComponentCreateOrUpdateWithModel(entityId, CLASS_ID_COMPONENT.SMART_ITEM, model);
 81
 182        Assert.IsTrue(biwEntity.HasSmartItemComponent());
 83
 184        DCLName name = (DCLName) scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME));
 185        scene.SharedComponentAttach(biwEntity.rootEntity.entityId, name.id);
 86
 187        DCLName dclName = biwEntity.rootEntity.TryGetComponent<DCLName>();
 188        Assert.IsNotNull(dclName);
 89
 190        string newName = "TestingName";
 191        dclName.SetNewName(newName);
 192        Assert.AreEqual(newName, biwEntity.GetDescriptiveName());
 93
 94
 195        DCLLockedOnEdit entityLocked = (DCLLockedOnEdit) scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.
 196        scene.SharedComponentAttach(biwEntity.rootEntity.entityId, entityLocked.id);
 97
 198        DCLLockedOnEdit dclLockedOnEdit = biwEntity.rootEntity.TryGetComponent<DCLLockedOnEdit>();
 199        Assert.IsNotNull(dclLockedOnEdit);
 100
 1101        bool isLocked = true;
 1102        dclLockedOnEdit.SetIsLocked(isLocked);
 1103        Assert.AreEqual(biwEntity.IsLocked, isLocked);
 1104    }
 105
 106    protected override IEnumerator TearDown()
 107    {
 3108        AssetCatalogBridge.i.ClearCatalog();
 3109        BIWCatalogManager.ClearCatalog();
 3110        yield return base.TearDown();
 3111    }
 112}