< Summary

Class:MineSweeper.Cell
Assembly:MineSweeper
File(s):/home/runner/work/KATA-MineSweeper-20210502b/KATA-MineSweeper-20210502b/src/MineSweeper/Cell.cs
Covered lines:21
Uncovered lines:0
Coverable lines:21
Total lines:42
Line coverage:100% (21 of 21)
Covered branches:9
Total branches:12
Branch coverage:75% (9 of 12)
Tag:52_817390446

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
.ctor()0%110100%
.ctor(...)0%110100%
SetBomb()0%220100%
Click()100%442100%
ToString()72.73%7.3362466.67%

File(s)

/home/runner/work/KATA-MineSweeper-20210502b/KATA-MineSweeper-20210502b/src/MineSweeper/Cell.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Linq;
 3
 4namespace MineSweeper
 5{
 6    public class Cell
 7    {
 38        public Cell() : this(Enumerable.Empty<Cell>())
 39        {
 310        }
 11
 7812        public Cell(IEnumerable<Cell> nearCellGenerator) => NearCellGenerator = nearCellGenerator;
 13
 14        public bool IsBomb { get; private set; }
 15        public int NearBombsCount { get; set; }
 3916        public bool IsCovered { get; private set; } = true;
 17        public IEnumerable<Cell> NearCellGenerator { get; }
 18
 19        public void SetBomb()
 620        {
 621            IsBomb = true;
 2322            NearCellGenerator.ForEach(x => x.NearBombsCount++);
 623        }
 24
 25        public void Click()
 2226        {
 3427            if (IsCovered is false) return;
 1028            else IsCovered = false;
 29
 1430            if (NearBombsCount is not 0) return;
 31
 2532            NearCellGenerator.ForEach(x => x.Click());
 2233        }
 34
 1235        public override string ToString() => this switch
 1236        {
 1437            { IsCovered: true } => ".",
 1338            { IsBomb: true } => "*",
 2139            _ => NearBombsCount.ToString(),
 1240        };
 41    }
 42}