Skip to content

Commit

Permalink
Refactor ToKeys method to ToStringKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
jsakamoto committed Dec 2, 2023
1 parent 51be3e1 commit bc92ae4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions HotKeys2.Test/HotKeyEntryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ public void ToString_for_ByCode_Test()
}

[Test]
public void ToKeys_for_ByCode_Test()
public void ToStringKeys_for_ByCode_Test()
{
var ctrl_alt_f12 = new HotKeyEntryByCode(null!, ModCode.Ctrl | ModCode.Alt, Code.F12, _ => ValueTask.CompletedTask, null, new() { Description = "Set the volume level to 10." });
ctrl_alt_f12.ToKeys().IsStructuralEqual(new[] { "Ctrl", "Alt", "F12" });
ctrl_alt_f12.ToStringKeys().IsStructuralEqual(new[] { "Ctrl", "Alt", "F12" });

var meta_one = new HotKeyEntryByCode(null!, ModCode.Meta, Code.Num1, _ => ValueTask.CompletedTask, null, new() { Description = "Launch the notepad." });
meta_one.ToKeys().IsStructuralEqual(new[] { "Meta", "1" });
meta_one.ToStringKeys().IsStructuralEqual(new[] { "Meta", "1" });

var u = new HotKeyEntryByCode(null!, ModCode.None, Code.U, _ => ValueTask.CompletedTask, null, new() { Description = "Increment counter." });
u.ToKeys().IsStructuralEqual(new[] { "U" });
u.ToStringKeys().IsStructuralEqual(new[] { "U" });
}

[Test]
public void ToKeys_for_ByKey_Test()
public void ToStringKeys_for_ByKey_Test()
{
var hotKeyEntry = new HotKeyEntryByKey(null!, ModKey.None, Key.Question, _ => ValueTask.CompletedTask, null, new() { Description = "Show help." });
hotKeyEntry.ToKeys().IsStructuralEqual(new[] { "?" });
hotKeyEntry.ToStringKeys().IsStructuralEqual(new[] { "?" });
}
}
4 changes: 2 additions & 2 deletions HotKeys2/HotKeyEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ protected void CommonProcess(Func<ValueTask> action)
/// <param name="format">{0} will be replaced with key combination text, and {1} will be replaced with description of this hotkey entry object.</param>
public string ToString(string format)
{
var keyComboText = string.Join(" + ", this.ToKeys());
var keyComboText = string.Join(" + ", this.ToStringKeys());
return string.Format(format, keyComboText, this.Description);
}

/// <summary>
/// Returns an array of String formatted keys.
/// </summary>
public string[] ToKeys()
public string[] ToStringKeys()
{
var keyCombo = new List<string>();
if (this._Modifiers != 0)
Expand Down

0 comments on commit bc92ae4

Please sign in to comment.