Skip to content

Commit 919a8f0

Browse files
committed
Finally fixed issue #6.
1 parent 95f0125 commit 919a8f0

File tree

4 files changed

+183
-138
lines changed

4 files changed

+183
-138
lines changed

CommandLine.sln.DotSettings.user

+1-1
Large diffs are not rendered by default.

src/tests/CommandLine.Tests.csproj

+130-129
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,131 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>10.0.0</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{86E1AC34-ED2D-4E42-8B95-65208FEA36C2}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<RootNamespace>CommandLine.Tests</RootNamespace>
11-
<AssemblyName>CommandLine.Tests</AssemblyName>
12-
</PropertyGroup>
13-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14-
<DebugSymbols>true</DebugSymbols>
15-
<DebugType>full</DebugType>
16-
<Optimize>false</Optimize>
17-
<OutputPath>bin\Debug</OutputPath>
18-
<DefineConstants>DEBUG;UNIT_TESTS</DefineConstants>
19-
<ErrorReport>prompt</ErrorReport>
20-
<WarningLevel>4</WarningLevel>
21-
<ConsolePause>false</ConsolePause>
22-
</PropertyGroup>
23-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
24-
<DebugType>none</DebugType>
25-
<Optimize>false</Optimize>
26-
<OutputPath>bin\Release</OutputPath>
27-
<ErrorReport>prompt</ErrorReport>
28-
<WarningLevel>4</WarningLevel>
29-
<ConsolePause>false</ConsolePause>
30-
<DefineConstants>UNIT_TESTS</DefineConstants>
31-
</PropertyGroup>
32-
<PropertyGroup>
33-
<SignAssembly>true</SignAssembly>
34-
</PropertyGroup>
35-
<PropertyGroup>
36-
<AssemblyOriginatorKeyFile>CommandLine.snk</AssemblyOriginatorKeyFile>
37-
</PropertyGroup>
38-
<ItemGroup>
39-
<Reference Include="FluentAssertions">
40-
<HintPath>..\..\packages\FluentAssertions.2.0.0.1\lib\net40\FluentAssertions.dll</HintPath>
41-
</Reference>
42-
<Reference Include="System" />
43-
<Reference Include="System.Xml" />
44-
<Reference Include="System.Xml.Linq" />
45-
<Reference Include="xunit">
46-
<HintPath>..\..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
47-
</Reference>
48-
</ItemGroup>
49-
<ItemGroup>
50-
<Compile Include="..\SharedAssemblyInfo.cs">
51-
<Link>Properties\SharedAssemblyInfo.cs</Link>
52-
</Compile>
53-
<Compile Include="Unit\Attributes\AttributesFixture.cs" />
54-
<Compile Include="Unit\Attributes\HelpOptionAttributeFixture.cs" />
55-
<Compile Include="Unit\Attributes\OptionArrayAttributeFixture.cs" />
56-
<Compile Include="Unit\Attributes\ValueListAttributeFixture.cs" />
57-
<Compile Include="Unit\Attributes\ValueOptionAttributeFixture.cs" />
58-
<Compile Include="Unit\Infrastructure\ArgumentParserFixture.cs" />
59-
<Compile Include="Unit\Infrastructure\EnumeratorsFixture.cs" />
60-
<Compile Include="Unit\Infrastructure\OptionMapFixture.cs" />
61-
<Compile Include="Fakes\CommandLineOptionsBase.cs" />
62-
<Compile Include="Fakes\OptionsWithValueOptionExplicitIndex.cs" />
63-
<Compile Include="Fakes\OptionsWithValueOptionImplicitIndex.cs" />
64-
<Compile Include="Fakes\SimpleOptionsWithValueOptionAndValueList.cs" />
65-
<Compile Include="Fakes\SimpleOptionsWithValueOption.cs" />
66-
<Compile Include="Fakes\SimpleOptionsForStrict.cs" />
67-
<Compile Include="Fakes\OptionsWithVerbsHelp.cs" />
68-
<Compile Include="Fakes\OptionsWithVerbs.cs" />
69-
<Compile Include="Unit\Parser\ParserConfiguratorFixture.cs" />
70-
<Compile Include="Unit\Parser\ParserFixture.cs" />
71-
<Compile Include="Unit\Parser\ParserSettingsFixture.cs" />
72-
<Compile Include="Unit\Parser\MutuallyExclusiveParsingFixture.cs" />
73-
<Compile Include="Unit\Parser\NullableTypesParsingFixture.cs" />
74-
<Compile Include="Unit\Parser\OptionArrayAttributeParsingFixture.cs" />
75-
<Compile Include="Unit\Parser\SingletonFixture.cs" />
76-
<Compile Include="Unit\Parser\StrictFixture.cs" />
77-
<Compile Include="Unit\Parser\UnknownArgumentsFixture.cs" />
78-
<Compile Include="Unit\Parser\ValueListAttributeParsingFixture.cs" />
79-
<Compile Include="Unit\Parser\ValueOptionAttributeParsingFixture.cs" />
80-
<Compile Include="Unit\Parser\VerbsFixture.cs" />
81-
<Compile Include="Properties\AssemblyInfo.cs" />
82-
<Compile Include="Unit\BaseFixture.cs" />
83-
<Compile Include="Unit\ParserBaseFixture.cs" />
84-
<Compile Include="Unit\DebugStringUtil.cs" />
85-
<Compile Include="Fakes\BooleanSetOptions.cs" />
86-
<Compile Include="Fakes\ComplexOptions.cs" />
87-
<Compile Include="Fakes\MixedCaseOptions.cs" />
88-
<Compile Include="Fakes\NullableTypesOptions.cs" />
89-
<Compile Include="Fakes\NumberSetOptions.cs" />
90-
<Compile Include="Fakes\OptionsBase.cs" />
91-
<Compile Include="Fakes\OptionsWithDefaultSet.cs" />
92-
<Compile Include="Fakes\OptionsWithMultipleSet.cs" />
93-
<Compile Include="Fakes\OptionsWithMultipleSetAndOneOption.cs" />
94-
<Compile Include="Fakes\OptionsWithValueListMaximumThree.cs" />
95-
<Compile Include="Fakes\OptionsWithValueListMaximumZero.cs" />
96-
<Compile Include="Fakes\SimpleOptions.cs" />
97-
<Compile Include="Fakes\SimpleOptionsWithArray.cs" />
98-
<Compile Include="Fakes\SimpleOptionsWithArrayAndValueList.cs" />
99-
<Compile Include="Fakes\SimpleOptionsWithBadOptionArray.cs" />
100-
<Compile Include="Fakes\SimpleOptionsWithEnum.cs" />
101-
<Compile Include="Fakes\SimpleOptionsWithHelpOption.cs" />
102-
<Compile Include="Fakes\SimpleOptionsWithOptionList.cs" />
103-
<Compile Include="Fakes\SimpleOptionsWithValueList.cs" />
104-
<Compile Include="Fakes\SimpleOptionsWithDefaults.cs" />
105-
<Compile Include="Fakes\SimpleOptionsWithBadDefaults.cs" />
106-
<Compile Include="Fakes\SimpleOptionsWithDefaultArray.cs" />
107-
<Compile Include="Fakes\RPEOptions.cs" />
108-
<Compile Include="Fakes\SimpleOptionsForAutoBuid.cs" />
109-
<Compile Include="Fakes\OptionsForPlugInScenario.cs" />
110-
<Compile Include="Fakes\OptionsWithUIntArray.cs" />
111-
<Compile Include="Unit\Text\CopyrightInfoFixture.cs" />
112-
<Compile Include="Unit\Text\HeadingInfoFixture.cs" />
113-
<Compile Include="Unit\Text\HelpTextFixture.cs" />
114-
<Compile Include="Unit\Text\MultiLineTextAttributeFixture.cs" />
115-
<Compile Include="Unit\Text\VerbsHelpTextFixture.cs" />
116-
<Compile Include="Unit\Helpers\ReflectionUtilFixture.cs" />
117-
</ItemGroup>
118-
<ItemGroup>
119-
<None Include="CommandLine.snk" />
120-
<None Include="packages.config" />
121-
</ItemGroup>
122-
<ItemGroup>
123-
<ProjectReference Include="..\libcmdline\CommandLine.csproj">
124-
<Project>{5DEA2811-2FFA-4959-830B-CAD3ACACABEB}</Project>
125-
<Name>CommandLine</Name>
126-
</ProjectReference>
127-
</ItemGroup>
128-
<ItemGroup />
129-
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>10.0.0</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{86E1AC34-ED2D-4E42-8B95-65208FEA36C2}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<RootNamespace>CommandLine.Tests</RootNamespace>
11+
<AssemblyName>CommandLine.Tests</AssemblyName>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14+
<DebugSymbols>true</DebugSymbols>
15+
<DebugType>full</DebugType>
16+
<Optimize>false</Optimize>
17+
<OutputPath>bin\Debug</OutputPath>
18+
<DefineConstants>DEBUG;UNIT_TESTS</DefineConstants>
19+
<ErrorReport>prompt</ErrorReport>
20+
<WarningLevel>4</WarningLevel>
21+
<ConsolePause>false</ConsolePause>
22+
</PropertyGroup>
23+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
24+
<DebugType>none</DebugType>
25+
<Optimize>false</Optimize>
26+
<OutputPath>bin\Release</OutputPath>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
<ConsolePause>false</ConsolePause>
30+
<DefineConstants>UNIT_TESTS</DefineConstants>
31+
</PropertyGroup>
32+
<PropertyGroup>
33+
<SignAssembly>true</SignAssembly>
34+
</PropertyGroup>
35+
<PropertyGroup>
36+
<AssemblyOriginatorKeyFile>CommandLine.snk</AssemblyOriginatorKeyFile>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="FluentAssertions">
40+
<HintPath>..\..\packages\FluentAssertions.2.0.0.1\lib\net40\FluentAssertions.dll</HintPath>
41+
</Reference>
42+
<Reference Include="System" />
43+
<Reference Include="System.Xml" />
44+
<Reference Include="System.Xml.Linq" />
45+
<Reference Include="xunit">
46+
<HintPath>..\..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
47+
</Reference>
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="..\SharedAssemblyInfo.cs">
51+
<Link>Properties\SharedAssemblyInfo.cs</Link>
52+
</Compile>
53+
<Compile Include="Fakes\OptionsWithTwoArrays.cs" />
54+
<Compile Include="Unit\Attributes\AttributesFixture.cs" />
55+
<Compile Include="Unit\Attributes\HelpOptionAttributeFixture.cs" />
56+
<Compile Include="Unit\Attributes\OptionArrayAttributeFixture.cs" />
57+
<Compile Include="Unit\Attributes\ValueListAttributeFixture.cs" />
58+
<Compile Include="Unit\Attributes\ValueOptionAttributeFixture.cs" />
59+
<Compile Include="Unit\Infrastructure\ArgumentParserFixture.cs" />
60+
<Compile Include="Unit\Infrastructure\EnumeratorsFixture.cs" />
61+
<Compile Include="Unit\Infrastructure\OptionMapFixture.cs" />
62+
<Compile Include="Fakes\CommandLineOptionsBase.cs" />
63+
<Compile Include="Fakes\OptionsWithValueOptionExplicitIndex.cs" />
64+
<Compile Include="Fakes\OptionsWithValueOptionImplicitIndex.cs" />
65+
<Compile Include="Fakes\SimpleOptionsWithValueOptionAndValueList.cs" />
66+
<Compile Include="Fakes\SimpleOptionsWithValueOption.cs" />
67+
<Compile Include="Fakes\SimpleOptionsForStrict.cs" />
68+
<Compile Include="Fakes\OptionsWithVerbsHelp.cs" />
69+
<Compile Include="Fakes\OptionsWithVerbs.cs" />
70+
<Compile Include="Unit\Parser\ParserConfiguratorFixture.cs" />
71+
<Compile Include="Unit\Parser\ParserFixture.cs" />
72+
<Compile Include="Unit\Parser\ParserSettingsFixture.cs" />
73+
<Compile Include="Unit\Parser\MutuallyExclusiveParsingFixture.cs" />
74+
<Compile Include="Unit\Parser\NullableTypesParsingFixture.cs" />
75+
<Compile Include="Unit\Parser\OptionArrayAttributeParsingFixture.cs" />
76+
<Compile Include="Unit\Parser\SingletonFixture.cs" />
77+
<Compile Include="Unit\Parser\StrictFixture.cs" />
78+
<Compile Include="Unit\Parser\UnknownArgumentsFixture.cs" />
79+
<Compile Include="Unit\Parser\ValueListAttributeParsingFixture.cs" />
80+
<Compile Include="Unit\Parser\ValueOptionAttributeParsingFixture.cs" />
81+
<Compile Include="Unit\Parser\VerbsFixture.cs" />
82+
<Compile Include="Properties\AssemblyInfo.cs" />
83+
<Compile Include="Unit\BaseFixture.cs" />
84+
<Compile Include="Unit\ParserBaseFixture.cs" />
85+
<Compile Include="Unit\DebugStringUtil.cs" />
86+
<Compile Include="Fakes\BooleanSetOptions.cs" />
87+
<Compile Include="Fakes\ComplexOptions.cs" />
88+
<Compile Include="Fakes\MixedCaseOptions.cs" />
89+
<Compile Include="Fakes\NullableTypesOptions.cs" />
90+
<Compile Include="Fakes\NumberSetOptions.cs" />
91+
<Compile Include="Fakes\OptionsBase.cs" />
92+
<Compile Include="Fakes\OptionsWithDefaultSet.cs" />
93+
<Compile Include="Fakes\OptionsWithMultipleSet.cs" />
94+
<Compile Include="Fakes\OptionsWithMultipleSetAndOneOption.cs" />
95+
<Compile Include="Fakes\OptionsWithValueListMaximumThree.cs" />
96+
<Compile Include="Fakes\OptionsWithValueListMaximumZero.cs" />
97+
<Compile Include="Fakes\SimpleOptions.cs" />
98+
<Compile Include="Fakes\SimpleOptionsWithArray.cs" />
99+
<Compile Include="Fakes\SimpleOptionsWithArrayAndValueList.cs" />
100+
<Compile Include="Fakes\SimpleOptionsWithBadOptionArray.cs" />
101+
<Compile Include="Fakes\SimpleOptionsWithEnum.cs" />
102+
<Compile Include="Fakes\SimpleOptionsWithHelpOption.cs" />
103+
<Compile Include="Fakes\SimpleOptionsWithOptionList.cs" />
104+
<Compile Include="Fakes\SimpleOptionsWithValueList.cs" />
105+
<Compile Include="Fakes\SimpleOptionsWithDefaults.cs" />
106+
<Compile Include="Fakes\SimpleOptionsWithBadDefaults.cs" />
107+
<Compile Include="Fakes\SimpleOptionsWithDefaultArray.cs" />
108+
<Compile Include="Fakes\RPEOptions.cs" />
109+
<Compile Include="Fakes\SimpleOptionsForAutoBuid.cs" />
110+
<Compile Include="Fakes\OptionsForPlugInScenario.cs" />
111+
<Compile Include="Fakes\OptionsWithUIntArray.cs" />
112+
<Compile Include="Unit\Text\CopyrightInfoFixture.cs" />
113+
<Compile Include="Unit\Text\HeadingInfoFixture.cs" />
114+
<Compile Include="Unit\Text\HelpTextFixture.cs" />
115+
<Compile Include="Unit\Text\MultiLineTextAttributeFixture.cs" />
116+
<Compile Include="Unit\Text\VerbsHelpTextFixture.cs" />
117+
<Compile Include="Unit\Helpers\ReflectionUtilFixture.cs" />
118+
</ItemGroup>
119+
<ItemGroup>
120+
<None Include="CommandLine.snk" />
121+
<None Include="packages.config" />
122+
</ItemGroup>
123+
<ItemGroup>
124+
<ProjectReference Include="..\libcmdline\CommandLine.csproj">
125+
<Project>{5DEA2811-2FFA-4959-830B-CAD3ACACABEB}</Project>
126+
<Name>CommandLine</Name>
127+
</ProjectReference>
128+
</ItemGroup>
129+
<ItemGroup />
130+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
130131
</Project>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace CommandLine.Tests.Fakes
7+
{
8+
class OptionsWithTwoArrays
9+
{
10+
[Option('s', "source", Required = true, HelpText = "Source Word2007+ document path")]
11+
public string SourceDocument { get; set; }
12+
13+
[Option('o', "output", Required = true, HelpText = "Output Excel2007+ spreadsheet path")]
14+
public string OutputSpreadsheet { get; set; }
15+
16+
[OptionArray('h', "headers", Required = true, HelpText = "List of coords to cells with headers")]
17+
public uint[] Headers { get; set; }
18+
19+
[OptionArray('c', "content", Required = true, HelpText = "List of coords to cells with content")]
20+
public uint[] Content { get; set; }
21+
22+
[Option('v', "verbose", Required = false, DefaultValue = false, HelpText = "Print details during execution")]
23+
public bool Verbose { get; set; }
24+
}
25+
}

src/tests/Unit/Attributes/OptionArrayAttributeFixture.cs

+27-8
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,37 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
5-
using Xunit;
5+
using Xunit;
6+
using CommandLine.Tests.Fakes;
7+
using FluentAssertions;
68

79
namespace CommandLine.Tests.Unit.Attributes
8-
{
9-
10-
10+
{
1111
public class OptionArrayAttributeFixture
1212
{
13-
//[Fact]
14-
public void Should_correctly_parse_two_consecutive_arrays()
15-
{
16-
// TODO
13+
/// <summary>
14+
/// https://github.com/gsscoder/commandline/issues/6
15+
/// </summary>
16+
[Fact]
17+
public void Should_correctly_parse_two_consecutive_arrays()
18+
{
19+
// Given
20+
var options = new OptionsWithTwoArrays();
21+
var parser = new Parser();
22+
var argumets = new[] { "--source", @"d:/document.docx", "--output", @"d:/document.xlsx",
23+
"--headers", "1", "2", "3", "4", // first array
24+
"--content", "5", "6", "7", "8", "--verbose" // second array
25+
};
26+
27+
// When
28+
var result = parser.ParseArguments(argumets, options);
29+
30+
// Than
31+
result.Should().BeTrue();
32+
options.Headers.Should().HaveCount(c => c == 4);
33+
options.Headers.Should().ContainInOrder(new uint[] { 1, 2, 3, 4 });
34+
options.Content.Should().HaveCount(c => c == 4);
35+
options.Content.Should().ContainInOrder(new uint[] { 5, 6, 7, 8 });
1736
}
1837
}
1938
}

0 commit comments

Comments
 (0)