-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSimpleOptionsTests.cs
More file actions
40 lines (37 loc) · 1.71 KB
/
Copy pathSimpleOptionsTests.cs
File metadata and controls
40 lines (37 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MGR.CommandLineParser.Extensibility.ClassBased;
using MGR.CommandLineParser.Tests.Commands;
using Xunit;
namespace MGR.CommandLineParser.IntegrationTests.DefaultCommand
{
public class SimpleOptionsTests : ConsoleLoggingTestsBase
{
[Fact]
public async Task ParseWithValidArgs()
{
// Arrange
IEnumerable<string> args = new[] { "--str-value:custom value", "-i", "42", "Custom argument value", "-b" };
var expectedReturnCode = CommandParsingResultCode.Success;
var expectedStrValue = "custom value";
var expectedNbOfArguments = 1;
var expectedArgumentsValue = "Custom argument value";
var expectedIntValue = 42;
// Act
var actual = await CallParseWithDefaultCommand<IntTestCommand>(args);
// Assert
Assert.True(actual.IsValid);
Assert.Equal(expectedReturnCode, actual.ParsingResultCode);
Assert.IsAssignableFrom<IClassBasedCommandObject>(actual.CommandObject);
Assert.IsType<IntTestCommand>(((IClassBasedCommandObject)actual.CommandObject).Command);
var rawCommand = (IntTestCommand)((IClassBasedCommandObject)actual.CommandObject).Command;
Assert.Equal(expectedStrValue, rawCommand.StrValue);
Assert.Equal(expectedIntValue, rawCommand.IntValue);
Assert.Null(rawCommand.IntListValue);
Assert.Equal(expectedNbOfArguments, rawCommand.Arguments.Count);
Assert.Equal(expectedArgumentsValue, rawCommand.Arguments.Single());
Assert.True(rawCommand.BoolValue);
}
}
}