mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
Adding additional tests for property binding with value types
This commit is contained in:
parent
ebb1076dd0
commit
0bf97cb666
@ -15,6 +15,12 @@ namespace Spectre.Console.Tests.Data
|
||||
{
|
||||
[CommandArgument(0, "[NAMES]")]
|
||||
public string[] Names { get; set; } = Array.Empty<string>();
|
||||
|
||||
[CommandOption("-c")]
|
||||
public int Count { get; set; } = 1;
|
||||
|
||||
[CommandOption("-v")]
|
||||
public int Value { get; set; } = 0;
|
||||
}
|
||||
|
||||
public sealed class OptionalArgumentWithDefaultValueAndTypeConverterSettings : CommandSettings
|
||||
|
@ -262,6 +262,9 @@ namespace Spectre.Console.Tests.Unit.Cli
|
||||
result.ExitCode.ShouldBe(0);
|
||||
result.Settings
|
||||
.ShouldBeOfType<OptionalArgumentWithPropertyInitializerSettings>()
|
||||
.And(settings => settings.Count.ShouldBe(1))
|
||||
.And(settings => settings.Value.ShouldBe(0))
|
||||
.And(settings => settings.Names.ShouldNotBeNull())
|
||||
.And(settings => settings.Names.ShouldNotBeNull())
|
||||
.And(settings => settings.Names.ShouldBeEmpty());
|
||||
}
|
||||
@ -278,12 +281,14 @@ namespace Spectre.Console.Tests.Unit.Cli
|
||||
});
|
||||
|
||||
// When
|
||||
var result = app.Run("ABBA", "Herreys");
|
||||
var result = app.Run("-c", "0", "-v", "50", "ABBA", "Herreys");
|
||||
|
||||
// Then
|
||||
result.ExitCode.ShouldBe(0);
|
||||
result.Settings
|
||||
.ShouldBeOfType<OptionalArgumentWithPropertyInitializerSettings>()
|
||||
.And(settings => settings.Count.ShouldBe(0))
|
||||
.And(settings => settings.Value.ShouldBe(50))
|
||||
.And(settings => settings.Names.ShouldContain("ABBA"))
|
||||
.And(settings => settings.Names.ShouldContain("Herreys"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user