< Summary

Class:DCL.Components.BaseComponent
Assembly:DCL.Runtime.Interfaces
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/Interfaces/BaseComponent.cs
Covered lines:27
Uncovered lines:3
Coverable lines:30
Total lines:77
Line coverage:90% (27 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
get_componentName()0%110100%
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;
 10612        public Coroutine routine => updateHandler.routine;
 013        public bool isRoutineRunning => updateHandler.isRoutineRunning;
 14
 28915        public IParcelScene scene { get; set; }
 16
 9887817        public IDCLEntity entity { get; set; }
 18
 82919        public IPoolableObject poolableObject { get; set; }
 20
 8721        string IComponent.componentName => componentName;
 22
 23        public abstract string componentName { get; }
 24
 25        protected BaseModel model;
 26
 16227        public void RaiseOnAppliedChanges() { }
 28
 29        public virtual void Initialize(IParcelScene scene, IDCLEntity entity)
 30        {
 12131            this.scene = scene;
 12132            this.entity = entity;
 33
 12134            if (transform.parent != entity.gameObject.transform)
 12135                transform.SetParent(entity.gameObject.transform, false);
 12136        }
 37
 32838        public virtual void UpdateFromJSON(string json) { UpdateFromModel(model.GetDataFromJSON(json)); }
 39
 40        public virtual void UpdateFromModel(BaseModel newModel)
 41        {
 16942            model = newModel;
 16943            updateHandler.ApplyChangesIfModified(model);
 16944        }
 45
 46        public abstract IEnumerator ApplyChanges(BaseModel model);
 47
 48        protected void OnEnable()
 49        {
 44650            if (updateHandler == null)
 44151                updateHandler = CreateUpdateHandler();
 44652        }
 53
 254        public virtual BaseModel GetModel() => model;
 55
 44156        protected virtual ComponentUpdateHandler CreateUpdateHandler() { return new ComponentUpdateHandler(this); }
 57
 16958        public bool IsValid() { return this != null; }
 59
 60        public virtual void Cleanup()
 61        {
 40262            updateHandler?.Cleanup();
 40263        }
 64
 1065        public virtual void OnPoolRelease() { Cleanup(); }
 66
 67        public virtual void OnPoolGet()
 68        {
 569            if (updateHandler == null)
 070                updateHandler = CreateUpdateHandler();
 571        }
 72
 73        public abstract int GetClassId();
 74
 3475        public Transform GetTransform() => transform;
 76    }
 77}