< Summary

Class:InternalECSComponent[T]
Assembly:ECS7Plugin.InternalECSComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/InternalECSComponents/InternalECSComponent.cs
Covered lines:12
Uncovered lines:2
Coverable lines:14
Total lines:49
Line coverage:85.7% (12 of 14)
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%
GetForAll()0%110100%
Dispose()0%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using DCL.Controllers;
 4using DCL.ECSRuntime;
 5using DCL.Models;
 6
 7public class InternalECSComponent<T> : IInternalECSComponent<T>
 8{
 9    private readonly ECSComponentsFactory componentsFactory;
 10    private readonly int componentId;
 11    private readonly ECSComponent<T> component;
 12
 6413    public InternalECSComponent(InternalECSComponentsId id,
 14        ECSComponentsManager componentsManager,
 15        ECSComponentsFactory componentsFactory,
 16        Func<IECSComponentHandler<T>> handlerBuilder)
 17    {
 6418        this.componentId = (int)id;
 6419        this.componentsFactory = componentsFactory;
 20
 12321        componentsFactory.AddOrReplaceComponent<T>(componentId, x => (T)x, handlerBuilder);
 6422        component = (ECSComponent<T>)componentsManager.GetOrCreateComponent(componentId);
 6423    }
 24
 25    public void PutFor(IParcelScene scene, IDCLEntity entity, T model)
 26    {
 5927        scene.crdtExecutor.ExecuteWithoutStoringState(entity.entityId, componentId, model);
 5928    }
 29
 30    public void RemoveFor(IParcelScene scene, IDCLEntity entity)
 31    {
 2132        scene.crdtExecutor.ExecuteWithoutStoringState(entity.entityId, componentId, null);
 2133    }
 34
 35    public IECSReadOnlyComponentData<T> GetFor(IParcelScene scene, IDCLEntity entity)
 36    {
 8237        return component.Get(scene, entity);
 38    }
 39
 40    public IReadOnlyList<KeyValueSetTriplet<IParcelScene, long, ECSComponentData<T>>> GetForAll()
 41    {
 1242        return component.Get();
 43    }
 44
 45    public void Dispose()
 46    {
 047        componentsFactory.RemoveComponent(componentId);
 048    }
 49}