|
|
@ -1,64 +1,64 @@
|
|
|
|
using System;
|
|
|
|
//using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
//using System.Diagnostics;
|
|
|
|
using FluentAssertions;
|
|
|
|
//using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
//using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
//using NUnit.Framework;
|
|
|
|
using Ninject;
|
|
|
|
//using Ninject;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
//using NzbDrone.Common;
|
|
|
|
using NzbDrone.Common.Model;
|
|
|
|
//using NzbDrone.Common.Model;
|
|
|
|
using NzbDrone.Providers;
|
|
|
|
//using NzbDrone.Providers;
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
//using NzbDrone.Test.Common;
|
|
|
|
using NzbDrone.Test.Dummy;
|
|
|
|
//using NzbDrone.Test.Dummy;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.App.Test
|
|
|
|
//namespace NzbDrone.App.Test
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
[TestFixture]
|
|
|
|
// [TestFixture]
|
|
|
|
public class IISProviderFixture : TestBase
|
|
|
|
// public class IISProviderFixture : TestBase
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
[Test]
|
|
|
|
// [Test]
|
|
|
|
public void should_update_pid_env_varibles()
|
|
|
|
// public void should_update_pid_env_varibles()
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
WithTempAsAppPath();
|
|
|
|
// WithTempAsAppPath();
|
|
|
|
|
|
|
|
|
|
|
|
var dummy = StartDummyProcess();
|
|
|
|
// var dummy = StartDummyProcess();
|
|
|
|
|
|
|
|
|
|
|
|
Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PID, "0");
|
|
|
|
// Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PID, "0");
|
|
|
|
Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PATH, "Test");
|
|
|
|
// Environment.SetEnvironmentVariable(EnviromentProvider.NZBDRONE_PATH, "Test");
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ProcessProvider>()
|
|
|
|
// Mocker.GetMock<ProcessProvider>()
|
|
|
|
.Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
|
|
|
|
// .Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
|
|
|
|
.Returns(dummy);
|
|
|
|
// .Returns(dummy);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<IISProvider>().StartServer();
|
|
|
|
// Mocker.Resolve<IISProvider>().StartServer();
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
// [Test]
|
|
|
|
public void should_set_iis_procces_id()
|
|
|
|
// public void should_set_iis_procces_id()
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
WithTempAsAppPath();
|
|
|
|
// WithTempAsAppPath();
|
|
|
|
var dummy = StartDummyProcess();
|
|
|
|
// var dummy = StartDummyProcess();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ProcessProvider>()
|
|
|
|
// Mocker.GetMock<ProcessProvider>()
|
|
|
|
.Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
|
|
|
|
// .Setup(c => c.Start(It.IsAny<ProcessStartInfo>()))
|
|
|
|
.Returns(dummy);
|
|
|
|
// .Returns(dummy);
|
|
|
|
|
|
|
|
|
|
|
|
//act
|
|
|
|
// //act
|
|
|
|
Mocker.Resolve<IISProvider>().StartServer();
|
|
|
|
// Mocker.Resolve<IISProvider>().StartServer();
|
|
|
|
|
|
|
|
|
|
|
|
//assert
|
|
|
|
// //assert
|
|
|
|
Mocker.Resolve<IISProvider>().IISProcessId.Should().Be(dummy.Id);
|
|
|
|
// Mocker.Resolve<IISProvider>().IISProcessId.Should().Be(dummy.Id);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Process StartDummyProcess()
|
|
|
|
// public Process StartDummyProcess()
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
|
|
|
|
// var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
|
|
|
|
startInfo.UseShellExecute = false;
|
|
|
|
// startInfo.UseShellExecute = false;
|
|
|
|
startInfo.RedirectStandardOutput = true;
|
|
|
|
// startInfo.RedirectStandardOutput = true;
|
|
|
|
startInfo.RedirectStandardError = true;
|
|
|
|
// startInfo.RedirectStandardError = true;
|
|
|
|
startInfo.CreateNoWindow = true;
|
|
|
|
// startInfo.CreateNoWindow = true;
|
|
|
|
return new ProcessProvider().Start(startInfo);
|
|
|
|
// return new ProcessProvider().Start(startInfo);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//}
|
|
|
|