< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
TestEntityOutsidePublish()0%110100%
TestEntityInsidePublish()0%330100%
TestMetricsPublish()0%220100%
TearDown()0%330100%

File(s)

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

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using DCL.Components;
 4using DCL.Helpers;
 5using DCL.Models;
 6using Newtonsoft.Json;
 7using NSubstitute.Extensions;
 8using NUnit.Framework;
 9using UnityEngine;
 10using UnityEngine.TestTools;
 11
 12public class BIWPublishShould : IntegrationTestSuite_Legacy
 13{
 14    private BuilderInWorldController controller;
 15    private BIWPublishController biwPublishController;
 16    private BuilderInWorldEntityHandler biwEntityHandler;
 17
 18    private const string entityId = "E1";
 19
 20    protected override IEnumerator SetUp()
 21    {
 322        yield return base.SetUp();
 323        controller = Resources.FindObjectsOfTypeAll<BuilderInWorldController>()[0];
 24
 325        controller.InitGameObjects();
 326        controller.FindSceneToEdit();
 327        controller.InitControllers();
 28
 329        biwPublishController = controller.biwPublishController;
 330        biwPublishController.EnterEditMode(scene);
 31
 332        biwEntityHandler = controller.builderInWorldEntityHandler;
 333        biwEntityHandler.EnterEditMode(scene);
 334    }
 35
 36    [Test]
 37    public void TestEntityOutsidePublish()
 38    {
 39        //Arrange
 140        DCLBuilderInWorldEntity entity = biwEntityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero);
 41
 42        //Act
 143        entity.gameObject.transform.position = Vector3.one * 9999;
 44
 45        //Assert
 146        Assert.IsFalse(biwPublishController.CanPublish());
 147    }
 48
 49    [UnityTest]
 50    public IEnumerator TestEntityInsidePublish()
 51    {
 52        //Arrange
 153        DCLBuilderInWorldEntity entity = biwEntityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero);
 154        TestHelpers.CreateAndSetShape(scene, entity.rootEntity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.Ser
 55            new
 56            {
 57                src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb"
 58            }));
 59
 160        LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entity.rootEntity.entityId]);
 761        yield return new WaitUntil(() => gltfShape.alreadyLoaded);
 62
 63        //Act
 164        entity.rootEntity.gameObject.transform.position = new Vector3(5, 0, 5);
 65
 66        //Assert
 167        Assert.IsTrue(biwPublishController.CanPublish());
 168    }
 69
 70    [Test]
 71    public void TestMetricsPublish()
 72    {
 73        //Act
 40474        for (int i = 0; i < scene.metricsController.GetLimits().entities + 1; i++)
 75        {
 20176            TestHelpers.CreateSceneEntity(scene, entityId + i);
 77        }
 78
 79        //Assert
 180        Assert.IsFalse(biwPublishController.CanPublish());
 181    }
 82
 83    protected override IEnumerator TearDown()
 84    {
 385        controller.CleanItems();
 386        yield return base.TearDown();
 387    }
 88}