From 587d60495e01b1bdacc31acc7e15a87d7f441839 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 20 Jan 2021 01:02:49 -0500 Subject: add unit tests for KeybindList (#744) --- src/SMAPI/Utilities/Keybind.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Utilities/Keybind.cs') 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 @@ -9,6 +9,14 @@ namespace StardewModdingAPI.Utilities /// NOTE: this is part of , and usually shouldn't be used directly. public class Keybind { + /********* + ** Fields + *********/ + /// Get the current input state for a button. + [Obsolete("This property should only be used for unit tests.")] + internal Func GetButtonState { get; set; } = SGame.GetInputState; + + /********* ** Accessors *********/ @@ -97,7 +105,7 @@ namespace StardewModdingAPI.Utilities /// Get the keybind state relative to the previous tick. 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) -- cgit