Kill NzbDrone process if service couldn't be stopped.

better Process/Service handling.
This commit is contained in:
Keivan Beigi
2013-07-05 11:51:38 -07:00
parent 6e3aef8ab2
commit c1a75604fd
6 changed files with 71 additions and 46 deletions
+26 -7
View File
@@ -1,4 +1,5 @@
using System.ServiceProcess;
using System;
using System.ServiceProcess;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Test.Common;
@@ -16,23 +17,28 @@ namespace NzbDrone.Common.Test
public void Setup()
{
WindowsOnly();
if (Subject.ServiceExist(TEMP_SERVICE_NAME))
{
Subject.UnInstall(TEMP_SERVICE_NAME);
}
CleanupService();
}
[TearDown]
public void TearDown()
{
WindowsOnly();
CleanupService();
}
private void CleanupService()
{
if (Subject.ServiceExist(TEMP_SERVICE_NAME))
{
Subject.UnInstall(TEMP_SERVICE_NAME);
}
if (Subject.IsServiceRunning(ALWAYS_INSTALLED_SERVICE))
{
Subject.Stop(ALWAYS_INSTALLED_SERVICE);
}
}
[Test]
@@ -86,6 +92,19 @@ namespace NzbDrone.Common.Test
.Should().Be(ServiceControllerStatus.Stopped);
}
[Test]
public void should_throw_if_starting_a_running_serivce()
{
Subject.GetService(ALWAYS_INSTALLED_SERVICE).Status
.Should().NotBe(ServiceControllerStatus.Running);
Subject.Start(ALWAYS_INSTALLED_SERVICE);
Assert.Throws<InvalidOperationException>(() => Subject.Start(ALWAYS_INSTALLED_SERVICE));
ExceptionVerification.ExpectedWarns(1);
}
[Test]
public void Should_log_warn_if_on_stop_if_service_is_already_stopped()
{