< Summary

Class:DCL.Components.BaseComponent
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/BaseComponent.cs
Covered lines:22
Uncovered lines:7
Coverable lines:29
Total lines:72
Line coverage:75.8% (22 of 29)
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%2100%
CreateUpdateHandler()0%110100%
IsValid()0%110100%
Cleanup()0%110100%
OnPoolRelease()0%110100%
OnPoolGet()0%2.152066.67%
GetTransform()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/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
 4317        public IDCLEntity entity { get; set; }
 18
 10819        public IPoolableObject poolableObject { get; set; }
 20
 021        public string componentName => "BaseComponent";
 22
 23        protected BaseModel model;
 24
 11425        public void RaiseOnAppliedChanges() { }
 26
 27        public virtual void Initialize(IParcelScene scene, IDCLEntity entity)
 28        {
 7529            this.scene = scene;
 7530            this.entity = entity;
 31
 7532            if (transform.parent != entity.gameObject.transform)
 7533                transform.SetParent(entity.gameObject.transform, false);
 7534        }
 35
 21636        public virtual void UpdateFromJSON(string json) { UpdateFromModel(model.GetDataFromJSON(json)); }
 37
 38        public virtual void UpdateFromModel(BaseModel newModel)
 39        {
 11740            model = newModel;
 11741            updateHandler.ApplyChangesIfModified(model);
 11742        }
 43
 44        public abstract IEnumerator ApplyChanges(BaseModel model);
 45
 46        protected void OnEnable()
 47        {
 7648            if (updateHandler == null)
 7549                updateHandler = CreateUpdateHandler();
 7650        }
 51
 052        public virtual BaseModel GetModel() => model;
 53
 7554        protected virtual ComponentUpdateHandler CreateUpdateHandler() { return new ComponentUpdateHandler(this); }
 55
 11756        public bool IsValid() { return this != null; }
 57
 15058        public virtual void Cleanup() { updateHandler.Cleanup(); }
 59
 260        public virtual void OnPoolRelease() { Cleanup(); }
 61
 62        public virtual void OnPoolGet()
 63        {
 164            if (updateHandler == null)
 065                updateHandler = CreateUpdateHandler();
 166        }
 67
 68        public abstract int GetClassId();
 69
 3670        public Transform GetTransform() => transform;
 71    }
 72}