Skip to content

Commit

Permalink
Fixes issue Topshelf#259: Updating validation to allow spaces in serv…
Browse files Browse the repository at this point in the history
…ice and display names, since Windows allows them.
  • Loading branch information
splatteredbits authored and phatboyg committed May 3, 2016
1 parent 0951c3f commit 6b44d18
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/Topshelf.Tests/CommandLine_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ public void Should_create_an_install_host_with_description()
public void Should_create_an_install_host_with_service_name_and_instance_name()
{
Host host = HostFactory.New(x =>
{
x.Service<MyService>();
x.ApplyCommandLine("install -servicename \"Joe\" -instance \"42\"");
});
{
x.Service<MyService>();
x.ApplyCommandLine("install -servicename \"Joe\" -instance \"42\"");
});

Assert.IsInstanceOf<InstallHost>(host);
var installHost = (InstallHost)host;
Expand All @@ -145,6 +145,22 @@ public void Should_create_an_install_host_with_service_name_and_instance_name()
Assert.AreEqual("Joe$42", installHost.Settings.ServiceName);
}

[Test]
public void Should_create_and_install_host_with_service_name_containing_space()
{
Host host = HostFactory.New(x =>
{
x.Service<MyService>();
x.ApplyCommandLine("install -servicename \"Joe's Service\" -instance \"42\"");
});

Assert.IsInstanceOf<InstallHost>(host);
var installHost = (InstallHost)host;
Assert.AreEqual("Joe's Service", installHost.Settings.Name);
Assert.AreEqual("42", installHost.Settings.InstanceName);
Assert.AreEqual("Joe's Service$42", installHost.Settings.ServiceName);
}

[Test]
public void Should_create_an_install_host_to_start_automatically()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public IEnumerable<ValidateResult> Validate()
yield return this.Failure("Name", "must be specified and not empty");
else
{
var disallowed = new[] {' ', '\t', '\r', '\n', '\\', '/'};
var disallowed = new[] {'\t', '\r', '\n', '\\', '/'};
if (_settings.Name.IndexOfAny(disallowed) >= 0)
yield return this.Failure("Name", "must not contain whitespace, '/', or '\\' characters");
}
Expand Down

0 comments on commit 6b44d18

Please sign in to comment.