< Summary

Information
Class: GridForge.Grids.Topology.GridTopologyFactory
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/GridTopologyFactory.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 47
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TryCreate(...)100%1414100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Topology/GridTopologyFactory.cs

#LineLine coverage
 1//=======================================================================
 2// GridTopologyFactory.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024–present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using GridForge.Configuration;
 9
 10namespace GridForge.Grids.Topology;
 11
 12internal static class GridTopologyFactory
 13{
 14    public static bool TryCreate(GridConfiguration configuration, out IGridTopology? topology)
 15    {
 43416        topology = null;
 17
 43418        switch (configuration.TopologyKind)
 19        {
 20            case GridTopologyKind.RectangularPrism:
 21                {
 36922                    if (!GridTopologyMetrics.IsValid(configuration.TopologyKind, configuration.TopologyMetrics))
 23                    {
 324                        GridForgeLogger.Channel.Warn($"Rectangular-prism topology requires positive cell width, layer he
 325                        return false;
 26                    }
 27
 36628                    topology = new RectangularPrismTopology(configuration.TopologyMetrics);
 36629                    return true;
 30                }
 31            case GridTopologyKind.HexPrism:
 32                {
 6233                    if (!GridTopologyMetrics.IsValid(configuration.TopologyKind, configuration.TopologyMetrics))
 34                    {
 535                        GridForgeLogger.Channel.Warn($"Hex-prism topology requires positive cell radius and layer height
 536                        return false;
 37                    }
 38
 5739                    topology = new HexPrismTopology(configuration.TopologyMetrics);
 5740                    return true;
 41                }
 42            default:
 343                GridForgeLogger.Channel.Warn($"Grid topology '{configuration.TopologyKind}' is not implemented.");
 344                return false;
 45        }
 46    }
 47}