< Summary

Class:DCL.Components.CylinderShape
Assembly:DCL.Components.ParametrizedShape
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/ParametrizedShapes/CylinderShape.cs
Covered lines:14
Uncovered lines:1
Coverable lines:15
Total lines:51
Line coverage:93.3% (14 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Model()0%110100%
GetDataFromJSON(...)0%110100%
CylinderShape()0%110100%
GetClassId()0%2100%
GenerateGeometry()0%110100%
ShouldGenerateNewMesh(...)0%880100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/ParametrizedShapes/CylinderShape.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using DCL.Models;
 4using System;
 5using UnityEngine;
 6
 7namespace DCL.Components
 8{
 9    public class CylinderShape : ParametrizedShape<CylinderShape.Model>
 10    {
 11        [System.Serializable]
 12        new public class Model : BaseShape.Model
 13        {
 3314            public float radiusTop = 1f;
 3315            public float radiusBottom = 1f;
 3316            public float segmentsHeight = 1f;
 3317            public float segmentsRadial = 36f;
 18            public bool openEnded = false;
 19            public float? radius;
 3320            public float arc = 360f;
 21
 1622            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 23        }
 24
 2425        public CylinderShape() { model = new Model(); }
 26
 027        public override int GetClassId() { return (int) CLASS_ID.CYLINDER_SHAPE; }
 28
 29        public override Mesh GenerateGeometry()
 30        {
 631            var model = (Model) this.model;
 632            return PrimitiveMeshBuilder.BuildCylinder(50, model.radiusTop, model.radiusBottom, 2f, 0f, true, false);
 33        }
 34
 35        protected override bool ShouldGenerateNewMesh(BaseShape.Model newModel)
 36        {
 1637            if (currentMesh == null)
 1038                return true;
 39
 640            Model newCylinderModel = newModel as Model;
 641            var model = (Model) this.model;
 642            return newCylinderModel.radius != model.radius
 43                   || newCylinderModel.radiusTop != model.radiusTop
 44                   || newCylinderModel.radiusBottom != model.radiusBottom
 45                   || newCylinderModel.segmentsHeight != model.segmentsHeight
 46                   || newCylinderModel.segmentsRadial != model.segmentsRadial
 47                   || newCylinderModel.openEnded != model.openEnded
 48                   || newCylinderModel.arc != model.arc;
 49        }
 50    }
 51}