< Summary

Class:DCL.Components.BaseComponent
Assembly:WorldRuntimeInterfaces
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/Interfaces/BaseComponent.cs
Covered lines:24
Uncovered lines:6
Coverable lines:30
Total lines:75
Line coverage:80% (24 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RaiseOnAppliedChanges()0%110100%
Initialize(...)0%220100%
UpdateFromJSON(...)0%110100%
UpdateFromModel(...)0%110100%
OnEnable()0%220100%
GetModel()0%110100%
CreateUpdateHandler()0%110100%
IsValid()0%110100%
Cleanup()0%220100%
OnPoolRelease()0%110100%
OnPoolGet()0%2.152066.67%
GetTransform()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/Interfaces/BaseComponent.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Models;
 3using System.Collections;
 4using UnityEngine;
 5
 6namespace DCL.Components
 7{
 8    public abstract class BaseComponent : MonoBehaviour, IEntityComponent, IDelayedComponent, IPoolLifecycleHandler, IPo
 9    {
 10        protected ComponentUpdateHandler updateHandler;
 011        public CustomYieldInstruction yieldInstruction => updateHandler.yieldInstruction;
 012        public Coroutine routine => updateHandler.routine;
 013        public bool isRoutineRunning => updateHandler.isRoutineRunning;
 14
 015        public IParcelScene scene { get; set; }
 16
 31417        public IDCLEntity entity { get; set; }
 18
 5419        public IPoolableObject poolableObject { get; set; }
 20
 021        public string componentName => "BaseComponent";
 22
 23        protected BaseModel model;
 24
 14525        public void RaiseOnAppliedChanges() { }
 26
 27        public virtual void Initialize(IParcelScene scene, IDCLEntity entity)
 28        {
 10129            this.scene = scene;
 10130            this.entity = entity;
 31
 10132            if (transform.parent != entity.gameObject.transform)
 10133                transform.SetParent(entity.gameObject.transform, false);
 10134        }
 35
 27836        public virtual void UpdateFromJSON(string json) { UpdateFromModel(model.GetDataFromJSON(json)); }
 37
 38        public virtual void UpdateFromModel(BaseModel newModel)
 39        {
 14840            model = newModel;
 14841            updateHandler.ApplyChangesIfModified(model);
 14842        }
 43
 44        public abstract IEnumerator ApplyChanges(BaseModel model);
 45
 46        protected void OnEnable()
 47        {
 78848            if (updateHandler == null)
 78649                updateHandler = CreateUpdateHandler();
 78850        }
 51
 152        public virtual BaseModel GetModel() => model;
 53
 78654        protected virtual ComponentUpdateHandler CreateUpdateHandler() { return new ComponentUpdateHandler(this); }
 55
 14856        public bool IsValid() { return this != null; }
 57
 58        public virtual void Cleanup()
 59        {
 70460            updateHandler?.Cleanup();
 70461        }
 62
 463        public virtual void OnPoolRelease() { Cleanup(); }
 64
 65        public virtual void OnPoolGet()
 66        {
 267            if (updateHandler == null)
 068                updateHandler = CreateUpdateHandler();
 269        }
 70
 71        public abstract int GetClassId();
 72
 29273        public Transform GetTransform() => transform;
 74    }
 75}