< Summary

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

Coverage History

Metrics

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

File(s)

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

#LineLine coverage
 1// Copyright (c) 2020-2024 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;
 6using UnityEngine;
 7
 8namespace GDX.Developer.ConsoleCommands
 9{
 10#if UNITY_2022_2_OR_NEWER
 11    public class WatchConsoleCommand : ConsoleCommandBase
 12    {
 13        string m_Identifier;
 14        bool m_HasState;
 15        bool m_DesiredState;
 16
 17        public override bool Evaluate(float deltaTime)
 018        {
 019            if (m_HasState)
 020            {
 021                WatchProvider.SetState(WatchProvider.GetWatch(m_Identifier), m_DesiredState);
 022            }
 23            else
 024            {
 025                WatchProvider.ToggleState(WatchProvider.GetWatch(m_Identifier));
 026            }
 027            return true;
 028        }
 29
 30        /// <inheritdoc />
 31        public override string GetKeyword()
 732        {
 733            return "watch";
 734        }
 35
 36        /// <inheritdoc />
 37        public override string GetHelpUsage()
 038        {
 039            return "watch <identifier> [state]";
 040        }
 41
 42        /// <inheritdoc />
 43        public override string GetHelpMessage()
 044        {
 045            return "Toggles the enabled/disabled state of a watch based on its unique identifier, or sets a specific sta
 046        }
 47
 48        /// <inheritdoc />
 49        public override ConsoleCommandBase GetInstance(string context)
 050        {
 051            if (string.IsNullOrEmpty(context))
 052            {
 053                Debug.LogWarning("An identifier is required to find a watch.");
 054                return null;
 55            }
 56
 057            string[] split = context.Split(' ', StringSplitOptions.RemoveEmptyEntries);
 58
 059            if (!WatchProvider.HasWatch(split[0]))
 060            {
 061                Debug.LogWarning($"Unable to find watch '{context}'.");
 062                return null;
 63            }
 64
 065            if (split.Length > 1)
 066            {
 067                return new WatchConsoleCommand
 68                {
 69                    m_Identifier = split[0], m_DesiredState =  split[1].IsBooleanPositiveValue(), m_HasState = true
 70                };
 71            }
 072            return new WatchConsoleCommand { m_Identifier = split[0] };
 073        }
 74    }
 75#endif // UNITY_2022_2_OR_NEWER
 76}

Coverage by test methods







Methods/Properties

Evaluate(System.Single)
GetKeyword()
GetHelpUsage()
GetHelpMessage()
GetInstance(System.String)