< Summary

Information
Class: Rudim.CLI.UCI.UciClient
Assembly: Rudim
File(s): /home/runner/work/rudim/rudim/Rudim/CLI/UCI/UciClient.cs
Line coverage
51%
Covered lines: 15
Uncovered lines: 14
Coverable lines: 29
Total lines: 62
Line coverage: 51.7%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_DebugMode()100%11100%
Run(...)0%2040%
WriteId()100%210%

File(s)

/home/runner/work/rudim/rudim/Rudim/CLI/UCI/UciClient.cs

#LineLine coverage
 1using Rudim.Board;
 2using System;
 3using System.Collections.Generic;
 4using System.Linq;
 5
 6namespace Rudim.CLI.UCI
 7{
 8    public class UciClient : ICliCommand
 9    {
 10        private readonly Dictionary<string, IUciCommand> _commands;
 11        public BoardState Board;
 812        private bool _debugMode = true;
 813        public ref bool DebugMode => ref _debugMode;
 14
 815        public UciClient()
 16        {
 817            GoCommand goCommand = new GoCommand(this);
 818            _commands = new Dictionary<string, IUciCommand>
 819            {
 820                ["isready"] = new IsReadyCommand(this),
 821                ["position"] = new PositionCommand(this),
 822                ["go"] = goCommand,
 823                ["stop"] = new StopCommand(goCommand),
 824                ["ucinewgame"] = new UciNewGameCommand(this),
 825                ["debug"] = new DebugCommand(this)
 826            };
 827            Board = BoardState.Default();
 828        }
 29
 30        public void Run(string[] parameters)
 31        {
 032            WriteId();
 033            while (true)
 34            {
 035                string[] input = Console.ReadLine().Split(' ');
 036                string command = input[0];
 037                string[] commandParameters = input.Skip(1).ToArray();
 38
 039                if (command == "quit")
 40                {
 041                    Environment.Exit(0);
 42                }
 43
 044                if (_commands.ContainsKey(command))
 45                {
 046                    _commands[command].Run(commandParameters);
 47                }
 48                else
 49                {
 050                    CliClient.WriteLine($"Unknown command {command}");
 51                }
 52            }
 53        }
 54
 55        private static void WriteId()
 56        {
 057            CliClient.WriteLine("id name Rudim 1.4");
 058            CliClient.WriteLine("id author Vishnu B");
 059            CliClient.WriteLine("uciok");
 060        }
 61    }
 62}