< 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:23
Uncovered lines:6
Coverable lines:29
Total lines:72
Line coverage:79.3% (23 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%110100%
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/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
 5219        public IPoolableObject poolableObject { get; set; }
 20
 021        public string componentName => "BaseComponent";
 22
 23        protected BaseModel model;
 24
 14425        public void RaiseOnAppliedChanges() { }
 26
 27        public virtual void Initialize(IParcelScene scene, IDCLEntity entity)
 28        {
 10029            this.scene = scene;
 10030            this.entity = entity;
 31
 10032            if (transform.parent != entity.gameObject.transform)
 10033                transform.SetParent(entity.gameObject.transform, false);
 10034        }
 35
 27636        public virtual void UpdateFromJSON(string json) { UpdateFromModel(model.GetDataFromJSON(json)); }
 37
 38        public virtual void UpdateFromModel(BaseModel newModel)
 39        {
 14740            model = newModel;
 14741            updateHandler.ApplyChangesIfModified(model);
 14742        }
 43
 44        public abstract IEnumerator ApplyChanges(BaseModel model);
 45
 46        protected void OnEnable()
 47        {
 78648            if (updateHandler == null)
 78449                updateHandler = CreateUpdateHandler();
 78650        }
 51
 152        public virtual BaseModel GetModel() => model;
 53
 78454        protected virtual ComponentUpdateHandler CreateUpdateHandler() { return new ComponentUpdateHandler(this); }
 55
 14756        public bool IsValid() { return this != null; }
 57
 140458        public virtual void Cleanup() { updateHandler.Cleanup(); }
 59
 460        public virtual void OnPoolRelease() { Cleanup(); }
 61
 62        public virtual void OnPoolGet()
 63        {
 264            if (updateHandler == null)
 065                updateHandler = CreateUpdateHandler();
 266        }
 67
 68        public abstract int GetClassId();
 69
 29270        public Transform GetTransform() => transform;
 71    }
 72}