fixed multiple instances starting when updateing nzbdrone

pull/6/head
kay.one 11 years ago
parent 4ee148549f
commit 091ec312c8

@ -18,7 +18,13 @@ namespace NzbDrone.Common.Test
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c => c.Kill()); Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c =>
{
c.Kill();
c.WaitForExit();
});
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).Should().BeEmpty();
} }
[TearDown] [TearDown]
@ -51,13 +57,32 @@ namespace NzbDrone.Common.Test
{ {
var startInfo = new ProcessStartInfo(Path.Combine(Directory.GetCurrentDirectory(), DummyApp.DUMMY_PROCCESS_NAME + ".exe")); var startInfo = new ProcessStartInfo(Path.Combine(Directory.GetCurrentDirectory(), DummyApp.DUMMY_PROCCESS_NAME + ".exe"));
var process = Subject.Start(startInfo);
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should() Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should()
.BeFalse("Dummy process is already running"); .BeTrue("excepted one dummy process to be already running");
Subject.Start(startInfo).Should().NotBeNull();
process.Kill();
process.WaitForExit();
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should().BeFalse();
}
[Test]
public void Should_be_able_to_execute_process()
{
var process = Subject.ShellExecute(Path.Combine(Directory.GetCurrentDirectory(), DummyApp.DUMMY_PROCCESS_NAME + ".exe"));
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should() Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should()
.BeTrue("excepted one dummy process to be already running"); .BeTrue("excepted one dummy process to be already running");
process.Kill();
process.WaitForExit();
Subject.Exists(DummyApp.DUMMY_PROCCESS_NAME).Should().BeFalse();
} }
[Test] [Test]

@ -124,7 +124,6 @@ namespace NzbDrone.Common
process.BeginErrorReadLine(); process.BeginErrorReadLine();
process.BeginOutputReadLine(); process.BeginOutputReadLine();
process.Start();
return process; return process;
} }

Loading…
Cancel
Save