Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Keybinding.Test/ParsePhraseEmptyInputTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2023-2026 ktsu-dev contributors

namespace ktsu.Keybinding.Test;

using ktsu.Keybinding.Core.Services;

[TestClass]
public class ParsePhraseEmptyInputTests
{
[TestMethod]
[DataRow("")]
[DataRow(" ")]
[DataRow(null)]
public void ParsePhrase_BlankInput_ThrowsNamingPhraseString(string? phraseString)
{
KeybindingService service = new(new CommandRegistry(), new ProfileManager());

ArgumentException ex = Assert.ThrowsExactly<ArgumentException>(() => service.ParsePhrase(phraseString!));
Assert.AreEqual("phraseString", ex.ParamName, "The exception should name the caller's argument, not the Phrase constructor's.");
}
}
1 change: 1 addition & 0 deletions Keybinding/Contracts/IKeybindingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public interface IKeybindingService
/// </summary>
/// <param name="phraseString">The phrase string to parse</param>
/// <returns>Phrase containing the sequence of chords</returns>
/// <exception cref="ArgumentException">Thrown when phraseString is null or whitespace</exception>
public Phrase ParsePhrase(string phraseString);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Keybinding/Services/KeybindingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
throw new ArgumentException("Profile ID cannot be null or whitespace", nameof(id));
}

ArgumentException.ThrowIfNullOrWhiteSpace(name, nameof(name));

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

Check warning on line 39 in Keybinding/Services/KeybindingService.cs

View workflow job for this annotation

GitHub Actions / Analyze & Release

Remove this argument from the method call; it hides the caller information.

return _profileManager.CreateProfile(id, name, description);
}
Expand Down Expand Up @@ -179,7 +179,7 @@
{
if (string.IsNullOrWhiteSpace(phraseString))
{
return new Phrase([]);
throw new ArgumentException("Phrase string cannot be null or whitespace", nameof(phraseString));
}

// Split by comma to get individual chord strings
Expand Down
Loading