< 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
 4817        public IDCLEntity entity { get; set; }
 18
 11219        public IPoolableObject poolableObject { get; set; }
 20
 021        public string componentName => "BaseComponent";
 22
 23        protected BaseModel model;
 24
 11525        public void RaiseOnAppliedChanges() { }
 26
 27        public virtual void Initialize(IParcelScene scene, IDCLEntity entity)
 28        {
 7729            this.scene = scene;
 7730            this.entity = entity;
 31
 7732            if (transform.parent != entity.gameObject.transform)
 7733                transform.SetParent(entity.gameObject.transform, false);
 7734        }
 35
 22036        public virtual void UpdateFromJSON(string json) { UpdateFromModel(model.GetDataFromJSON(json)); }
 37
 38        public virtual void UpdateFromModel(BaseModel newModel)
 39        {
 11940            model = newModel;
 11941            updateHandler.ApplyChangesIfModified(model);
 11942        }
 43
 44        public abstract IEnumerator ApplyChanges(BaseModel model);
 45
 46        protected void OnEnable()
 47        {
 73848            if (updateHandler == null)
 73649                updateHandler = CreateUpdateHandler();
 73850        }
 51
 052        public virtual BaseModel GetModel() => model;
 53
 73654        protected virtual ComponentUpdateHandler CreateUpdateHandler() { return new ComponentUpdateHandler(this); }
 55
 11956        public bool IsValid() { return this != null; }
 57
 147658        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
 4170        public Transform GetTransform() => transform;
 71    }
 72}