Skip to content

Commit

Permalink
fixed #7
Browse files Browse the repository at this point in the history
  • Loading branch information
atEaE committed Feb 9, 2021
1 parent 1989142 commit d552f1b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 1 deletion.
Binary file added docs/wiki/arrow-chg.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/wiki/clear-menu.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/wiki/color-only.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/wiki/simple.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<PackageId>CommandLineSelectableMenu</PackageId>
<Title>CommandLineSelectableMenu</Title>
<Version>1.1.1</Version>
<Version>1.2.0</Version>
<Description>Provides a command line only selectable menu.</Description>
<AssemblyName>CommandLineSelectableMenu</AssemblyName>
<Authors>EtaAoki</Authors>
Expand Down
23 changes: 23 additions & 0 deletions src/CommandLineSelectableMenu/SelectableMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@ public class SelectableMenu<T>
public SelectableMenu()
: this(new SelectableMenuOptions())
{ }

/// <summary>
/// Create new selectable menu instance.
/// </summary>
/// <param name="action">function.</param>
public SelectableMenu(Action<SelectableMenuOptions> action)
{
if (action == null)
{
throw new ArgumentNullException(nameof(action));
}

var options = new SelectableMenuOptions();
action.Invoke(options);

if (options == null)
{
throw new ArgumentNullException(nameof(options));
}

items = new List<SelectableMenuItem<T>>();
this.options = options;
}

/// <summary>
/// Create new selectable menu instance.
Expand Down
22 changes: 22 additions & 0 deletions src/Test_CommandLineSelectableMenu/Test_SelectableMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ namespace Test_CommandLineSelectableMenu
{
public class Test_SelectableMenu
{
[Fact]
public void NullOptionsArguments()
{
var ex = Assert.Throws<ArgumentNullException>(() =>
{
SelectableMenuOptions options = null;
var selectableMenu = new SelectableMenu<string>(options);
});
ex.Message.Is("Value cannot be null. (Parameter 'options')");
}

[Fact]
public void NullActionArguments()
{
var ex = Assert.Throws<ArgumentNullException>(() =>
{
Action<SelectableMenuOptions> action = null;
var selectableMenu = new SelectableMenu<string>(action);
});
ex.Message.Is("Value cannot be null. (Parameter 'action')");
}

[Fact]
public void NullAdd()
{
Expand Down

0 comments on commit d552f1b

Please sign in to comment.