< Summary

Class:GDX.Developer.ConsoleVariables.StringConsoleVariable
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleVariables/StringConsoleVariable.cs
Covered lines:0
Uncovered lines:28
Coverable lines:28
Total lines:66
Line coverage:0% (0 of 28)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:8
Method coverage:0% (0 of 8)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
StringConsoleVariable(...)0%30500%
GetConsoleVariableType()0%2100%
GetBoxedValue()0%2100%
SetValueFromString(...)0%6200%
GetCurrentValueAsString()0%2100%
GetDefaultValueAsString()0%2100%
GetValue()0%2100%
SetValue(...)0%6200%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/ConsoleVariables/StringConsoleVariable.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;
 6
 7namespace GDX.Developer.ConsoleVariables
 8{
 9#if UNITY_2022_2_OR_NEWER
 10    public class StringConsoleVariable : ConsoleVariableBase
 11    {
 12        public Action<string> OnValueChanged;
 13        readonly string m_DefaultValue;
 14        string m_CurrentValue;
 15
 16        public StringConsoleVariable(string name, string description, string defaultValue,
 017            ConsoleVariableFlags flags = ConsoleVariableFlags.None) : base(name, description, flags)
 018        {
 019            m_DefaultValue = ConsoleVariableSettings.TryGetValue(name, out string settingsValue) ? settingsValue : defau
 020            m_CurrentValue = CommandLineParser.Arguments.ContainsKey(name) ? CommandLineParser.Arguments[name] : default
 021        }
 22
 23        /// <inheritdoc />
 24        public override ConsoleVariableType GetConsoleVariableType()
 025        {
 026            return ConsoleVariableType.String;
 027        }
 28
 29        /// <inheritdoc />
 30        public override object GetBoxedValue()
 031        {
 032            return m_CurrentValue;
 033        }
 34
 35        /// <inheritdoc />
 36        public sealed override void SetValueFromString(string newValue)
 037        {
 038            m_CurrentValue = newValue;
 039            OnValueChanged?.Invoke(m_CurrentValue);
 040        }
 41
 42        /// <inheritdoc />
 43        public override string GetCurrentValueAsString()
 044        {
 045            return m_CurrentValue;
 046        }
 47
 48        /// <inheritdoc />
 49        public override string GetDefaultValueAsString()
 050        {
 051            return m_DefaultValue;
 052        }
 53
 54        public string GetValue()
 055        {
 056            return m_CurrentValue;
 057        }
 58
 59        public void SetValue(string newValue)
 060        {
 061            m_CurrentValue = newValue;
 062            OnValueChanged?.Invoke(m_CurrentValue);
 063        }
 64    }
 65#endif // UNITY_2022_2_OR_NEWER
 66}