< Summary

Information
Class: Minesweeper.Prelude
Assembly: Minesweeper
File(s): /home/runner/work/kata-minesweeper-func1/kata-minesweeper-func1/src/Minesweeper/Prelude.cs
Tag: 26_1981553485
Line coverage
78%
Covered lines: 57
Uncovered lines: 16
Coverable lines: 73
Total lines: 94
Line coverage: 78%
Branch coverage
76%
Covered branches: 43
Total branches: 56
Branch coverage: 76.7%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Coverage History

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
click(...)50%280%
plus(...)100%16100%
get_bomb()100%1100%
get_zero()100%1100%
get_one()100%1100%
get_two()100%1100%
get_three()100%1100%
get_four()100%1100%
get_five()100%1100%
get_six()100%1100%
get_seven()100%1100%
get_eight()100%1100%
show(...)90.9%2292.85%
get_newMineField()100%1100%
.cctor()50%490.9%
index1D(...)50%875%
get_indexesNear()0%40%
get_ReplaceItem()100%1100%

File(s)

/home/runner/work/kata-minesweeper-func1/kata-minesweeper-func1/src/Minesweeper/Prelude.cs

#LineLine coverage
 1using LanguageExt;
 2using Minesweeper.Domain;
 3using static LanguageExt.Prelude;
 4
 5namespace Minesweeper;
 6
 7public static class Prelude
 8{
 19    public static ICell click(ICell cell) => cell switch
 110    {
 111        Covered c => c.Inner,
 012        _ => cell
 113    };
 14
 1015    public static ICell plus(ICell cell) => cell switch
 1016    {
 117        Zero => one,
 118        One => two,
 119        Two => three,
 120        Three => four,
 121        Four => five,
 122        Five => six,
 123        Six => seven,
 124        Seven => eight,
 225        _ => cell
 1026    };
 27
 428    public static Bomb bomb { get; } = new();
 329    public static Zero zero { get; } = new();
 530    public static One one { get; } = new();
 431    public static Two two { get; } = new();
 432    public static Three three { get; } = new();
 433    public static Four four { get; } = new();
 434    public static Five five { get; } = new();
 435    public static Six six { get; } = new();
 436    public static Seven seven { get; } = new();
 437    public static Eight eight { get; } = new();
 38
 1039    public static string show(ICell cell) => cell switch
 1040    {
 141        Covered => ".",
 042        Zero => " ",
 143        One => "1",
 144        Two => "2",
 145        Three => "3",
 146        Four => "4",
 147        Five => "5",
 148        Six => "6",
 149        Seven => "7",
 150        Eight => "8",
 151        Bomb => "*",
 1052    };
 53
 154    public static Func<Width, Func<Height, MineField>> newMineField { get; private set; } =
 255        width => height =>
 356            new MineField(width, height, Enumerable.Repeat<ICell>(zero, width.Value * height.Value).ToArr());
 57
 158    public static Option<int> index1D(X x, Y y, MineField @this) => (x.Value, y.Value) switch
 159    {
 060        ( < 0, _) => None,
 061        (_, < 0) => None,
 162        (var a, _) when a >= @this.Width.Value => None,
 163        (_, var a) when a >= @this.Height.Value => None,
 164        (var a, var b) => Some(b + a * @this.Width.Value)
 165    };
 66
 67    public static Func<MineField, Func<X, Func<Y, IEnumerable<int>>>> indexesNear =>
 068        @this => x => y =>
 069            from _1 in new List<(X X, Y Y)>
 070            {
 071                (-1, -1), (0, -1), (1, -1),
 072                (-1, 0), (1, 0),
 073                (-1, 1), (0, 1), (1, 1),
 074            }
 075            let _2 = (_1.X + x, _1.Y + y)
 076            let _3 = index1D(_2.Item1, _2.Item2, @this)
 077            where _3 != None
 078            select _3.Match(v => v, () => default);
 79
 80
 181    public static Func<MineField, Func<X, Func<Y, Func<Func<ICell, ICell>, MineField>>>> ReplaceItem { get; private set;
 482        @this => x => y => hof =>
 583            index1D(x, y, @this).Case switch
 584            {
 085                null => @this,
 186                int v => @this with
 187                {
 188                    Cells = @this.Cells.SetItem(v, hof(@this.Cells[v]))
 189                }
 590            };
 91
 92
 93}
 94