Skip to content

Commit 7a465d5

Browse files
committed
Merge pull request #18 from jen20/no-short-options
Implementation for #17
2 parents 083b3b5 + 977a1d8 commit 7a465d5

20 files changed

+206
-198
lines changed

FluentCommandLineParser.Tests/FluentCommandLineParser.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@
127127
<Compile Include="FluentCommandLineParser\when_setting_up_a_new_option\with_a_short_name\with_a_short_name_that_contains_a_colon.cs" />
128128
<Compile Include="FluentCommandLineParser\when_setting_up_a_new_option\with_a_short_name\with_a_short_name_that_contains_whitespace.cs" />
129129
<Compile Include="FluentCommandLineParser\when_setting_up_a_new_option\with_a_short_name\with_a_short_name_that_is_already_used.cs" />
130-
<Compile Include="FluentCommandLineParser\when_setting_up_a_new_option\with_a_short_name\with_a_short_name_that_is_empty.cs" />
131-
<Compile Include="FluentCommandLineParser\when_setting_up_a_new_option\with_a_short_name\with_a_short_name_that_is_null.cs" />
130+
<Compile Include="FluentCommandLineParser\when_setting_up_a_new_option\with_a_short_name\with_a_short_name_that_is_a_control_char.cs" />
132131
<Compile Include="FluentCommandLineParser\when_setting_up_a_new_option\with_a_short_name\with_a_short_name_that_is_whitespace.cs" />
133132
<Compile Include="HelperExtensions.cs" />
134133
<Compile Include="Internals\CommandLineOptionFactoryTests.cs" />

FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/SettingUpALongOptionTestContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public abstract class SettingUpALongOptionTestContext : SettingUpAShortOptionTes
3535
protected const string invalid_long_name_with_spaces = "long name";
3636
protected const string invalid_long_name_with_colon = "long:name";
3737
protected const string invalid_long_name_with_equality_sign = "long=name";
38-
protected const string valid_long_name = "l";
38+
protected const string valid_long_name = "long";
3939

40-
protected static void SetupOptionWith(string shortName, string longName)
40+
protected static void SetupOptionWith(char shortName, string longName)
4141
{
4242
CatchAnyError(() =>
4343
{

FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/SettingUpAShortOptionTestContext.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ namespace TestContext
3333
[Subject(Subjects.setup_new_option)]
3434
public abstract class SettingUpAShortOptionTestContext : FluentCommandLineParserTestContext
3535
{
36-
protected const string invalid_short_name_that_is_empty = "";
37-
protected const string invalid_short_name_that_is_whitespace = " ";
38-
protected const string invalid_short_name_with_spaces = "short name";
39-
protected const string invalid_short_name_with_colon = "short:name";
40-
protected const string invalid_short_name_with_equality_sign = "short=name";
41-
protected const string valid_short_name = "s";
36+
protected const char invalid_short_name_that_is_whitespace = ' ';
37+
protected const char invalid_short_name_with_colon = ':';
38+
protected const char invalid_short_name_with_equality_sign = '=';
39+
protected const char invalid_short_name_that_is_a_control_char = (char) 7;
40+
protected const char valid_short_name = 's';
4241

4342
protected static ICommandLineOption option;
4443

45-
protected static void SetupOptionWith(string shortName)
44+
protected static void SetupOptionWith(char shortName)
4645
{
4746
CatchAnyError(() =>
4847
{

FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/and_the_option_factory/returns_a_null_option.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#endregion
2424

2525
using System;
26+
using System.Globalization;
2627
using Fclp.Internals;
2728
using Fclp.Tests.FluentCommandLineParser.TestContext;
2829
using Machine.Specifications;
@@ -41,7 +42,7 @@ public class returns_a_null_option : SettingUpALongOptionTestContext
4142

4243
var mockOptionFactoryThatReturnsNull = new Mock<ICommandLineOptionFactory>();
4344
mockOptionFactoryThatReturnsNull
44-
.Setup(x => x.CreateOption<TestType>(valid_short_name, valid_long_name))
45+
.Setup(x => x.CreateOption<TestType>(valid_short_name.ToString(CultureInfo.InvariantCulture), valid_long_name))
4546
.Returns(nullOption);
4647

4748
sut.OptionFactory = mockOptionFactoryThatReturnsNull.Object;

FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/and_the_option_factory/throws_an_error.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// POSSIBILITY OF SUCH DAMAGE.
2323
#endregion
2424

25+
using System.Globalization;
2526
using Fclp.Internals;
2627
using Fclp.Tests.FluentCommandLineParser.TestContext;
2728
using Machine.Specifications;
@@ -40,7 +41,7 @@ public class throws_an_error : SettingUpALongOptionTestContext
4041

4142
var mockOptionFactoryThatReturnsNull = new Mock<ICommandLineOptionFactory>();
4243
mockOptionFactoryThatReturnsNull
43-
.Setup(x => x.CreateOption<TestType>(valid_short_name, valid_long_name))
44+
.Setup(x => x.CreateOption<TestType>(valid_short_name.ToString(CultureInfo.InvariantCulture), valid_long_name))
4445
.Throws<TestException>();
4546

4647
sut.OptionFactory = mockOptionFactoryThatReturnsNull.Object;

FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// POSSIBILITY OF SUCH DAMAGE.
2323
#endregion
2424

25+
using System.Globalization;
2526
using Fclp.Tests.FluentCommandLineParser.TestContext;
2627
using Machine.Specifications;
2728

@@ -36,7 +37,7 @@ public class with_a_long_name : SettingUpALongOptionTestContext
3637
Because of = () => SetupOptionWith(valid_short_name, valid_long_name);
3738

3839
It should_return_a_new_option = () => option.ShouldNotBeNull();
39-
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name);
40+
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture));
4041
It should_have_the_given_long_name = () => option.LongName.ShouldMatch(valid_long_name);
4142
It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse();
4243
It should_have_no_callback = () => option.HasCallback.ShouldBeFalse();

FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_is_empty.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// POSSIBILITY OF SUCH DAMAGE.
2323
#endregion
2424

25+
using System.Globalization;
2526
using Fclp.Tests.FluentCommandLineParser.TestContext;
2627
using Machine.Specifications;
2728

@@ -36,7 +37,7 @@ public class with_a_long_name_that_is_empty : SettingUpALongOptionTestContext
3637
Because of = () => SetupOptionWith(valid_short_name, valid_long_name_that_is_empty);
3738

3839
It should_return_a_new_option = () => option.ShouldNotBeNull();
39-
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name);
40+
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture));
4041
It should_have_the_given_long_name = () => option.LongName.ShouldMatch(valid_long_name_that_is_empty);
4142
It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse();
4243
It should_have_no_callback = () => option.HasCallback.ShouldBeFalse();

FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_is_valid.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// POSSIBILITY OF SUCH DAMAGE.
2323
#endregion
2424

25+
using System.Globalization;
2526
using Fclp.Tests.FluentCommandLineParser.TestContext;
2627
using Machine.Specifications;
2728

@@ -36,7 +37,7 @@ public class with_a_long_name_that_is_valid : SettingUpALongOptionTestContext
3637
Because of = () => SetupOptionWith(valid_short_name, null);
3738

3839
It should_return_a_new_option = () => option.ShouldNotBeNull();
39-
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name);
40+
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture));
4041
It should_have_the_given_long_name = () => option.LongName.ShouldBeNull();
4142
It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse();
4243
It should_have_no_callback = () => option.HasCallback.ShouldBeFalse();

FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// POSSIBILITY OF SUCH DAMAGE.
2323
#endregion
2424

25+
using System.Globalization;
2526
using Fclp.Tests.FluentCommandLineParser.TestContext;
2627
using Machine.Specifications;
2728

@@ -36,7 +37,7 @@ public class with_a_short_name : SettingUpAShortOptionTestContext
3637
Because of = () => SetupOptionWith(valid_short_name);
3738

3839
It should_return_a_new_option = () => option.ShouldNotBeNull();
39-
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name);
40+
It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture));
4041
It should_have_no_long_name = () => option.HasLongName.ShouldBeFalse();
4142
It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse();
4243
It should_have_no_callback = () => option.HasCallback.ShouldBeFalse();

FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_contains_whitespace.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class with_a_short_name_that_contains_whitespace : SettingUpAShortOptionT
3434
{
3535
Establish context = AutoMockAll;
3636

37-
Because of = () => SetupOptionWith(invalid_short_name_with_spaces);
37+
Because of = () => SetupOptionWith(invalid_short_name_that_is_whitespace);
3838

3939
Behaves_like<InvalidOptionSetupBehaviour> a_failed_setup_option;
4040
}

0 commit comments

Comments
 (0)