< Summary

Class:MineSweeper.MineFieldHelper
Assembly:MineSweeper
File(s):/home/runner/work/KATA-MineSweeper-20210502b/KATA-MineSweeper-20210502b/src/MineSweeper/MineFieldHelper.cs
Covered lines:20
Uncovered lines:0
Coverable lines:20
Total lines:38
Line coverage:100% (20 of 20)
Covered branches:0
Total branches:0
Tag:52_817390446

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RandomIndexGenerator()0%330100%
NearPosGenerator()0%11110100%
NearCellGenerator(...)0%330100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Security.Cryptography;
 5
 6namespace MineSweeper
 7{
 8    public static class MineFieldHelper
 9    {
 10        public static IEnumerable<(int X, int Y)> RandomIndexGenerator(int width, int height)
 111        {
 312            while (true)
 313            {
 314                yield return (RandomNumberGenerator.GetInt32(width),
 315                              RandomNumberGenerator.GetInt32(height));
 216            }
 17        }
 18
 19        public static IEnumerable<(int X, int Y)> NearPosGenerator(int x, int y)
 1120        {
 1121            yield return (x - 1, y - 1);
 1122            yield return (x, y - 1);
 1123            yield return (x + 1, y - 1);
 1124            yield return (x - 1, y);
 1125            yield return (x + 1, y);
 1126            yield return (x - 1, y + 1);
 1127            yield return (x, y + 1);
 1128            yield return (x + 1, y + 1);
 1129        }
 30
 31        public static IEnumerable<Cell> NearCellGenerator(int x, int y, Func<(int, int), Cell> getCellFunc) =>
 3632            from nearPos in NearPosGenerator(x, y)
 11633            let cell = getCellFunc(nearPos)
 11634            where cell is not null
 7235            select cell;
 36
 37    }
 38}