diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-01-20 01:02:49 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-01-20 01:02:49 -0500 |
commit | 587d60495e01b1bdacc31acc7e15a87d7f441839 (patch) | |
tree | df43368ad1308fc7a3f2f290d4f08f2349775795 /src/SMAPI | |
parent | e40483aab1f6dbcb89f3a1fd1639fc732fe987fc (diff) | |
download | SMAPI-587d60495e01b1bdacc31acc7e15a87d7f441839.tar.gz SMAPI-587d60495e01b1bdacc31acc7e15a87d7f441839.tar.bz2 SMAPI-587d60495e01b1bdacc31acc7e15a87d7f441839.zip |
add unit tests for KeybindList (#744)
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Utilities/Keybind.cs | 10 | ||||
-rw-r--r-- | src/SMAPI/Utilities/KeybindList.cs | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/SMAPI/Utilities/Keybind.cs b/src/SMAPI/Utilities/Keybind.cs index 9d6cd6ee..dd8d2861 100644 --- a/src/SMAPI/Utilities/Keybind.cs +++ b/src/SMAPI/Utilities/Keybind.cs @@ -10,6 +10,14 @@ namespace StardewModdingAPI.Utilities public class Keybind { /********* + ** Fields + *********/ + /// <summary>Get the current input state for a button.</summary> + [Obsolete("This property should only be used for unit tests.")] + internal Func<SButton, SButtonState> GetButtonState { get; set; } = SGame.GetInputState; + + + /********* ** Accessors *********/ /// <summary>The buttons that must be down to activate the keybind.</summary> @@ -97,7 +105,7 @@ namespace StardewModdingAPI.Utilities /// <summary>Get the keybind state relative to the previous tick.</summary> public SButtonState GetState() { - SButtonState[] states = this.Buttons.Select(SGame.GetInputState).Distinct().ToArray(); + SButtonState[] states = this.Buttons.Select(this.GetButtonState).Distinct().ToArray(); // single state if (states.Length == 1) diff --git a/src/SMAPI/Utilities/KeybindList.cs b/src/SMAPI/Utilities/KeybindList.cs index 4ae66ab7..1845285a 100644 --- a/src/SMAPI/Utilities/KeybindList.cs +++ b/src/SMAPI/Utilities/KeybindList.cs @@ -72,7 +72,7 @@ namespace StardewModdingAPI.Utilities if (rawErrors.Any()) { parsed = null; - errors = rawErrors.ToArray(); + errors = rawErrors.Distinct().ToArray(); return false; } else |