Skip to content

Commit

Permalink
Fixes for Command-Line options are case sensitive
Browse files Browse the repository at this point in the history
These are fixes for the command line options being case insensitive. The
fixes should work for the argument and switches.
  • Loading branch information
Naveen authored and phatboyg committed Dec 3, 2015
1 parent 201c430 commit fa78255
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/Topshelf.Tests/CommandLine_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ public void Should_create_an_install_host()

Assert.IsInstanceOf<InstallHost>(host);
}
[Test]
public void Should_create_an_install_host_without_being_case_sensitive()
{
Host host = HostFactory.New(x =>
{
x.Service<MyService>();
x.ApplyCommandLine("Install");
});

Assert.IsInstanceOf<InstallHost>(host);
}
[Test]
public void Should_throw_an_exception_on_an_invalid_command_line()
{
Expand Down Expand Up @@ -163,6 +173,20 @@ public void Should_create_an_install_host_to_start_manually()
Assert.AreEqual(HostStartMode.Manual, installHost.InstallSettings.StartMode);
}

[Test]
public void Should_create_an_install_host_to_start_manually_without_being_case_sensitive()
{
Host host = HostFactory.New(x =>
{
x.Service<MyService>();
x.ApplyCommandLine("InstAll --ManuAl");
});

Assert.IsInstanceOf<InstallHost>(host);
var installHost = (InstallHost)host;
Assert.AreEqual(HostStartMode.Manual, installHost.InstallSettings.StartMode);
}

[Test]
public void Should_create_an_install_host_to_set_disabled()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Topshelf.Tests/Topshelf.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where c.GetType() == typeof(SwitchElement)
public Parser<IEnumerable<ICommandLineElement>, ISwitchElement> Switch(string key)
{
return from sw in Switch()
where sw.Key == key
where string.Equals(sw.Key, key, StringComparison.OrdinalIgnoreCase)
select sw;
}

Expand All @@ -100,7 +100,7 @@ where c.GetType() == typeof(ArgumentElement)
public Parser<IEnumerable<ICommandLineElement>, IArgumentElement> Argument(string value)
{
return from arg in Argument()
where arg.Id == value
where string.Equals(arg.Id, value, StringComparison.OrdinalIgnoreCase)
select arg;
}

Expand Down

0 comments on commit fa78255

Please sign in to comment.