Example #1
0
    //TODO: When refactoring these tests to split them by shape, replicate this on them
    public IEnumerator UpdateVisibilityInMultipleEntities(int entitiesCount, bool visible)
    {
        SceneController.i.useBoundariesChecker = false;

        // Arrange: set inverse of visible to trigger is dirty later
        BaseShape shapeComponent = TestHelpers.SharedComponentCreate <BoxShape, BaseShape.Model>(scene, CLASS_ID.BOX_SHAPE, new BaseShape.Model {
            visible = !visible
        });

        yield return(shapeComponent.routine);

        List <DecentralandEntity> entities = new List <DecentralandEntity>();

        for (int i = 0; i < entitiesCount; i++)
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene, $"entity{i}");
            TestHelpers.SharedComponentAttach(shapeComponent, entity);
            entities.Add(entity);
        }

        // Act: Update visible
        yield return(shapeComponent.ApplyChanges(JsonUtility.ToJson(new BaseShape.Model {
            visible = visible
        })));

        // Assert:
        foreach (DecentralandEntity entity in entities)
        {
            for (int i = 0; i < entity.meshesInfo.renderers.Length; i++)
            {
                Assert.AreEqual(visible, entity.meshesInfo.renderers[i].enabled);
            }
        }
    }
    //TODO: When refactoring these tests to split them by shape, replicate this on them
    public IEnumerator UpdateWithCollisionInMultipleEntities(int entitiesCount, bool withCollision)
    {
        Environment.i.world.sceneBoundsChecker.Stop();

        // Arrange: set inverse of withCollision to trigger is dirty later
        BaseShape shapeComponent = TestHelpers.SharedComponentCreate <BoxShape, BaseShape.Model>(scene, CLASS_ID.BOX_SHAPE, new BaseShape.Model {
            withCollisions = !withCollision
        });

        yield return(shapeComponent.routine);

        List <DecentralandEntity> entities = new List <DecentralandEntity>();

        for (int i = 0; i < entitiesCount; i++)
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene, $"entity{i}");
            TestHelpers.SharedComponentAttach(shapeComponent, entity);
            entities.Add(entity);
        }

        // Act: Update withCollision
        yield return(shapeComponent.ApplyChanges(JsonUtility.ToJson(new BaseShape.Model {
            withCollisions = withCollision
        })));

        // Assert:
        foreach (DecentralandEntity entity in entities)
        {
            for (int i = 0; i < entity.meshesInfo.colliders.Count; i++)
            {
                Assert.AreEqual(withCollision, entity.meshesInfo.colliders[i].enabled);
            }
        }
    }