< Summary

Class:DCL.UUIDComponent
Assembly:DCL.Components.Events
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UUIDEventComponentsPlugin/UUIDComponent/UUIDComponent.cs
Covered lines:8
Uncovered lines:11
Coverable lines:19
Total lines:68
Line coverage:42.1% (8 of 19)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:7
Method coverage:42.8% (3 of 7)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDataFromJSON(...)0%2100%
GetDataFromPb(...)0%20400%
GetClassIdFromType()0%6.116085.71%
ApplyChanges(...)0%6200%
GetClassId()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UUIDEventComponentsPlugin/UUIDComponent/UUIDComponent.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL.Components;
 4using DCL.Helpers;
 5using DCL.Models;
 6using Decentraland.Sdk.Ecs6;
 7
 8namespace DCL
 9{
 10    public class UUIDComponent : BaseComponent
 11    {
 12        [Serializable]
 13        public class Model : BaseModel
 14        {
 15            public string type;
 16            public string uuid;
 17
 18            public override BaseModel GetDataFromJSON(string json) =>
 019                Utils.SafeFromJson<Model>(json);
 20
 21            public override BaseModel GetDataFromPb(ComponentBodyPayload pbModel)
 22            {
 023                if (pbModel.PayloadCase != ComponentBodyPayload.PayloadOneofCase.UuidCallback)
 024                    return Utils.SafeUnimplemented<UUIDComponent, Model>(expected: ComponentBodyPayload.PayloadOneofCase
 25
 026                var pb = new Model();
 027                if (pbModel.UuidCallback.HasUuid) pb.uuid = pbModel.UuidCallback.Uuid;
 028                if (pbModel.UuidCallback.HasType) pb.type = pbModel.UuidCallback.Type;
 29
 030                return pb;
 31            }
 32
 33            public CLASS_ID_COMPONENT GetClassIdFromType()
 34            {
 7035                switch (type)
 36                {
 37                    case OnPointerDown.NAME:
 2138                        return CLASS_ID_COMPONENT.UUID_ON_DOWN;
 39                    case OnPointerUp.NAME:
 940                        return CLASS_ID_COMPONENT.UUID_ON_UP;
 41                    case OnClick.NAME:
 2142                        return CLASS_ID_COMPONENT.UUID_ON_CLICK;
 43                    case OnPointerHoverEnter.NAME:
 1344                        return CLASS_ID_COMPONENT.UUID_ON_HOVER_ENTER;
 45                    case OnPointerHoverExit.NAME:
 646                        return CLASS_ID_COMPONENT.UUID_ON_HOVER_EXIT;
 47                }
 48
 049                return CLASS_ID_COMPONENT.UUID_CALLBACK;
 50            }
 51        }
 52
 3853        public override string componentName => uuidComponentName;
 54
 3055        protected virtual string uuidComponentName { get; }
 56
 57        public override IEnumerator ApplyChanges(BaseModel newModel)
 58        {
 059            this.model = newModel ?? new Model();
 060            return null;
 61        }
 62
 63        public override int GetClassId()
 64        {
 065            return (int) CLASS_ID_COMPONENT.UUID_CALLBACK;
 66        }
 67    }
 68}