< Summary

Class:Minesweeper.Cell
Assembly:Minesweeper
File(s):/home/runner/work/KATA-Minesweeper-20210527/KATA-Minesweeper-20210527/src/Minesweeper/Cell.cs
Covered lines:29
Uncovered lines:0
Coverable lines:29
Total lines:53
Line coverage:100% (29 of 29)
Covered branches:10
Total branches:12
Branch coverage:83.3% (10 of 12)
Tag:28_1324931658

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
.ctor()0%110100%
.ctor(...)0%110100%
SetBomb()0%110100%
Click()100%554100%
ToString()77.78%5.9351666.67%

File(s)

/home/runner/work/KATA-Minesweeper-20210527/KATA-Minesweeper-20210527/src/Minesweeper/Cell.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4
 5namespace Minesweeper
 6{
 7    public class Cell
 8    {
 39        public Cell() : this((0,0), Enumerable.Empty<Cell>())
 310        {
 11
 312        }
 13
 3914        public Cell((int x, int y) p, IEnumerable<Cell> enumerable)
 3915        {
 3916            XY = p;
 3917            NearCellGenerator = enumerable;
 3918        }
 19
 20        public bool IsBomb { get; set; }
 21        public int NearBombsCount { get; set; }
 3922        public bool IsCover { get; private set; } = true;
 23        public (int x, int y) XY { get; }
 24        public IEnumerable<Cell> NearCellGenerator { get; }
 25
 26        public void SetBomb()
 727        {
 728            IsBomb = true;
 729        }
 30
 31        public void Click()
 2232        {
 3433            if (IsCover is not true) return;
 34
 1035            IsCover = false;
 36
 1037            if (NearBombsCount == 0)
 738            {
 5939                foreach (var nearcell in NearCellGenerator)
 1940                {
 1941                    nearcell.Click();
 1942                }
 743            }
 2244        }
 45
 1246        public override string ToString() => (IsCover, IsBomb, NearBombsCount) switch
 1247        {
 1448            (true, _, _) => ".",
 1349            (false, true, _) => "*",
 2150            (false, false, var m) => m.ToString()
 1251        };
 52    }
 53}