< Summary

Class:GDX.Developer.ConsoleCommands.HelpConsoleCommand
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleCommands/HelpConsoleCommand.cs
Covered lines:3
Uncovered lines:31
Coverable lines:34
Total lines:65
Line coverage:8.8% (3 of 34)
Covered branches:0
Total branches:0
Covered methods:1
Total methods:4
Method coverage:25% (1 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Evaluate(...)0%20400%
GetAccessLevel()0%2100%
GetKeyword()0%110100%
GetHelpMessage()0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleCommands/HelpConsoleCommand.cs

#LineLine coverage
 1// Copyright (c) 2020-2022 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System.Collections.Generic;
 6
 7namespace GDX.Developer.ConsoleCommands
 8{
 9#if UNITY_2022_2_OR_NEWER
 10    public class HelpConsoleCommand : ConsoleCommandBase
 11    {
 12        /// <inheritdoc />
 13        public override bool Evaluate(float deltaTime)
 014        {
 015            TextGenerator textGenerator = new TextGenerator();
 016            List<string> sortedCommands = new List<string>(Console.GetCommandKeywordsCopy());
 017            sortedCommands.Sort();
 018            int commandCount = sortedCommands.Count;
 019            Console.ConsoleAccessLevel maxAccessLevel = Console.GetAccessLevel();
 020            for (int i = 0; i < commandCount; i++)
 021            {
 022                ConsoleCommandBase command = Console.GetCommand(sortedCommands[i]);
 23
 24                // Dont show commands that are not usable.
 025                if (command.GetAccessLevel() > maxAccessLevel)
 026                {
 027                    continue;
 28                }
 29
 030                textGenerator.AppendLine(command.GetHelpUsage());
 031                textGenerator.Append($"\t{command.GetHelpMessage()}");
 032                if (command.IsEditorOnly())
 033                {
 034                    textGenerator.AppendLine("(Editor Only)");
 035                }
 36                else
 037                {
 038                    textGenerator.AppendLine();
 039                }
 040            }
 41
 042            UnityEngine.Debug.Log(textGenerator.ToString());
 043            return true;
 044        }
 45
 46        /// <inheritdoc />
 47        public override Console.ConsoleAccessLevel GetAccessLevel()
 048        {
 049            return Console.ConsoleAccessLevel.Anonymous;
 050        }
 51
 52        /// <inheritdoc />
 53        public override string GetKeyword()
 754        {
 755            return "help";
 756        }
 57
 58        /// <inheritdoc />
 59        public override string GetHelpMessage()
 060        {
 061            return "Display a list of all known commands and their usage.";
 062        }
 63    }
 64#endif // UNITY_2022_2_OR_NEWER
 65}

Coverage by test methods







Methods/Properties

Evaluate(System.Single)
GetAccessLevel()
GetKeyword()
GetHelpMessage()