< Summary

Information
Class: Morpho25.Geometry.NestingGrids
Assembly: Morpho25
File(s): D:\a\Morpho\Morpho\project\Morpho\Morpho25\Geometry\NestingGrids.cs
Line coverage
64%
Covered lines: 33
Uncovered lines: 18
Coverable lines: 51
Total lines: 117
Line coverage: 64.7%
Branch coverage
50%
Covered branches: 9
Total branches: 18
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_FirstMaterial()100%1100%
get_SecondMaterial()100%1100%
get_NumberOfCells()100%1100%
.ctor()100%1100%
.ctor(...)100%1100%
Equals(...)50%1080%
Equals(...)0%40%
GetHashCode()100%10%
op_Equality(...)100%4100%
op_Inequality(...)100%1100%

File(s)

D:\a\Morpho\Morpho\project\Morpho\Morpho25\Geometry\NestingGrids.cs

#LineLine coverage
 1using Newtonsoft.Json;
 2using System;
 3using System.ComponentModel;
 4using System.ComponentModel.DataAnnotations;
 5
 6namespace Morpho25.Geometry
 7{
 8    /// <summary>
 9    /// Nesting grids class.
 10    /// </summary>
 11    public class NestingGrids : IEquatable<NestingGrids>
 12    {
 13        [DisplayName("First Material")]
 14        [Description("First profile material to use.")]
 15        [MinLength(6, ErrorMessage = "The value cannot exceed 6 characters.")]
 16        [MaxLength(6, ErrorMessage = "The value cannot exceed 6 characters.")]
 17        [JsonProperty("firstMaterial")]
 18        /// <summary>
 19        /// First material.
 20        /// </summary>
 1821        public string FirstMaterial { get; private set; }
 22
 23        [DisplayName("Second Material")]
 24        [Description("Second profile material to use.")]
 25        [MinLength(6, ErrorMessage = "The value cannot exceed 6 characters.")]
 26        [MaxLength(6, ErrorMessage = "The value cannot exceed 6 characters.")]
 27        [JsonProperty("secondMaterial")]
 28        /// <summary>
 29        /// Second material.
 30        /// </summary>
 1831        public string SecondMaterial { get; private set; }
 32
 33        [DisplayName("Number Of Cells")]
 34        [Description("Number of cell to add to domain.")]
 35        [JsonProperty("numberOfCells")]
 36        /// <summary>
 37        /// Number of cells.
 38        /// </summary>
 1839        public uint NumberOfCells { get; private set; }
 40
 41        /// <summary>
 42        /// Create a new nesting grids object.
 43        /// </summary>
 444        public NestingGrids()
 445        {
 446            NumberOfCells = 0;
 447            FirstMaterial = Material.DEFAULT_SOIL;
 448            SecondMaterial = Material.DEFAULT_SOIL;
 449        }
 50
 51        [JsonConstructor]
 52        /// <summary>
 53        /// Create a new nesting grids object.
 54        /// </summary>
 55        /// <param name="numberOfCells">Number of cells.</param>
 56        /// <param name="firstMaterial">First material.</param>
 57        /// <param name="secondMaterial">Second material.</param>
 858        public NestingGrids(uint numberOfCells,
 859            string firstMaterial,
 860            string secondMaterial)
 861        {
 862            NumberOfCells = numberOfCells;
 863            FirstMaterial = firstMaterial;
 864            SecondMaterial = secondMaterial;
 865        }
 66        public bool Equals(NestingGrids other)
 267        {
 268            if (other == null)
 069                return false;
 70
 271            if (other != null
 272                && other.NumberOfCells == this.NumberOfCells
 273                && other.FirstMaterial == this.FirstMaterial
 274                && other.SecondMaterial == this.SecondMaterial)
 275                return true;
 76            else
 077                return false;
 278        }
 79
 80        public override bool Equals(Object obj)
 081        {
 082            if (obj == null)
 083                return false;
 84
 085            var faceObj = obj as NestingGrids;
 086            if (faceObj == null)
 087                return false;
 88            else
 089                return Equals(faceObj);
 090        }
 91
 92        public override int GetHashCode()
 093        {
 94            unchecked
 095            {
 096                int hash = 17;
 097                hash = hash * 23 + FirstMaterial.GetHashCode();
 098                hash = hash * 23 + SecondMaterial.GetHashCode();
 099                hash = hash * 23 + NumberOfCells.GetHashCode();
 0100                return hash;
 101            }
 0102        }
 103
 104        public static bool operator ==(NestingGrids nesting1, NestingGrids nesting2)
 25105        {
 25106            if (((object)nesting1) == null || ((object)nesting2) == null)
 23107                return Object.Equals(nesting1, nesting2);
 108
 2109            return nesting1.Equals(nesting2);
 25110        }
 111
 112        public static bool operator !=(NestingGrids nesting1, NestingGrids nesting2)
 2113        {
 2114            return !(nesting1 == nesting2);
 2115        }
 116    }
 117}