< Summary

Class:InternalECSComponent[T]
Assembly:ECS7Plugin.InternalECSComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/InternalECSComponents/InternalECSComponent.cs
Covered lines:11
Uncovered lines:2
Coverable lines:13
Total lines:43
Line coverage:84.6% (11 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
InternalECSComponent(...)0%220100%
PutFor(...)0%110100%
RemoveFor(...)0%110100%
GetFor(...)0%110100%
Dispose()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/InternalECSComponents/InternalECSComponent.cs

#LineLine coverage
 1using System;
 2using DCL.Controllers;
 3using DCL.ECSRuntime;
 4using DCL.Models;
 5
 6public class InternalECSComponent<T> : IInternalECSComponent<T>
 7{
 8    private readonly ECSComponentsFactory componentsFactory;
 9    private readonly int componentId;
 10    private readonly ECSComponent<T> component;
 11
 412    public InternalECSComponent(InternalECSComponentsId id,
 13        ECSComponentsManager componentsManager,
 14        ECSComponentsFactory componentsFactory,
 15        Func<IECSComponentHandler<T>> handlerBuilder)
 16    {
 417        this.componentId = (int)id;
 418        this.componentsFactory = componentsFactory;
 19
 2720        componentsFactory.AddOrReplaceComponent<T>(componentId, x => (T)x, handlerBuilder);
 421        component = (ECSComponent<T>)componentsManager.GetOrCreateComponent(componentId);
 422    }
 23
 24    public void PutFor(IParcelScene scene, IDCLEntity entity, T model)
 25    {
 2326        scene.crdtExecutor.ExecuteWithoutStoringState(entity.entityId, componentId, model);
 2327    }
 28
 29    public void RemoveFor(IParcelScene scene, IDCLEntity entity)
 30    {
 131        scene.crdtExecutor.ExecuteWithoutStoringState(entity.entityId, componentId, null);
 132    }
 33
 34    public IECSReadOnlyComponentData<T> GetFor(IParcelScene scene, IDCLEntity entity)
 35    {
 636        return component.Get(scene, entity);
 37    }
 38
 39    public void Dispose()
 40    {
 041        componentsFactory.RemoveComponent(componentId);
 042    }
 43}