< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreatePlatformContext()0%110100%
CreateRuntimeContext()0%110100%
BuilderInWorldChangeFeedbackStyleChange()0%110100%
BuilderInWorldRendererEnableOutsideParcel()0%550100%
TearDown()0%330100%

File(s)

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

#LineLine coverage
 1using DCL;
 2using DCL.Components;
 3using DCL.Helpers;
 4using DCL.Models;
 5using Newtonsoft.Json;
 6using NUnit.Framework;
 7using System.Collections;
 8using DCL.Controllers;
 9using Tests;
 10using UnityEngine;
 11using UnityEngine.TestTools;
 12using UnityGLTF;
 13
 14public class BIWSceneBoundarieShould : IntegrationTestSuite
 15{
 16    protected override PlatformContext CreatePlatformContext()
 17    {
 218        WebRequestController webRequestController = new WebRequestController();
 219        webRequestController.Initialize(
 20            genericWebRequest: new WebRequest(),
 21            assetBundleWebRequest: new WebRequestAssetBundle(),
 22            textureWebRequest: new WebRequestTexture(),
 23            null);
 24
 225        var context = DCL.Tests.PlatformContextFactory.CreateWithCustomMocks
 26        (
 27            webRequestController: webRequestController
 28        );
 29
 230        return context;
 31    }
 32
 33    protected override WorldRuntimeContext CreateRuntimeContext()
 34    {
 235        return DCL.Tests.WorldRuntimeContextFactory.CreateWithCustomMocks
 36        (
 37            sceneController: new SceneController(),
 38            state: new WorldState(),
 39            componentFactory: new RuntimeComponentFactory(),
 40            sceneBoundsChecker: new SceneBoundsChecker()
 41        );
 42    }
 43
 44    [Test]
 45    public void BuilderInWorldChangeFeedbackStyleChange()
 46    {
 47        //Arrange
 148        var biwStyle = new SceneBoundsFeedbackStyle_BIW();
 49
 50        //Act
 151        Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(biwStyle);
 52
 53        //Assert
 154        Assert.AreSame( Environment.i.world.sceneBoundsChecker.GetFeedbackStyle(), biwStyle );
 155    }
 56
 57    [UnityTest]
 58    public IEnumerator BuilderInWorldRendererEnableOutsideParcel()
 59    {
 60        //Arrange
 161        WebRequestController.Create();
 162        ParcelScene scene = (ParcelScene) Environment.i.world.sceneController.CreateTestScene();
 63
 164        Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(new SceneBoundsFeedbackStyle_Simple());
 165        var biwStyle = new SceneBoundsFeedbackStyle_BIW();
 166        string entityId = "1";
 167        TestHelpers.CreateSceneEntity(scene, entityId);
 68
 169        Assert.IsTrue(
 70            scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null,
 71            "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");
 72
 173        TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
 74            new
 75            {
 76                src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb"
 77            }));
 78
 179        LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
 780        yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded);
 81
 82        //Act
 183        scene.entities[entityId].gameObject.transform.position = new Vector3(100, 100, 100);
 184        Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(biwStyle);
 85
 186        yield return null;
 87
 88        //Assert
 489        foreach (var renderer in scene.entities[entityId].renderers)
 90        {
 191            Assert.IsTrue(renderer.enabled);
 92        }
 193    }
 94
 495    protected override IEnumerator TearDown() { yield return base.TearDown(); }
 96}