< 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
 9813    public InternalECSComponent(InternalECSComponentsId id,
 14        ECSComponentsManager componentsManager,
 15        ECSComponentsFactory componentsFactory,
 16        Func<IECSComponentHandler<T>> handlerBuilder)
 17    {
 9818        this.componentId = (int)id;
 9819        this.componentsFactory = componentsFactory;
 20
 17221        componentsFactory.AddOrReplaceComponent<T>(componentId, x => (T)x, handlerBuilder);
 9822        component = (ECSComponent<T>)componentsManager.GetOrCreateComponent(componentId);
 9823    }
 24
 25    public void PutFor(IParcelScene scene, IDCLEntity entity, T model)
 26    {
 7427        scene.crdtExecutor.ExecuteWithoutStoringState(entity.entityId, componentId, model);
 7428    }
 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    {
 8837        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}