Fixed some unit tests
This commit is contained in:
parent
d0a6daeb26
commit
4d3217432c
|
@ -23,11 +23,7 @@ namespace NzbDrone.App.Test
|
|||
[Test]
|
||||
public void should_continue_if_only_instance()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(c => c.FindProcessByName(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME))
|
||||
.Returns(new List<ProcessInfo>());
|
||||
|
||||
Mocker.GetMock<IProcessProvider>().Setup(c => c.FindProcessByName(ProcessProvider.NZB_DRONE_PROCESS_NAME))
|
||||
Mocker.GetMock<INzbDroneProcessProvider>().Setup(c => c.FindNzbDroneProcesses())
|
||||
.Returns(new List<ProcessInfo>
|
||||
{
|
||||
new ProcessInfo{Id = CURRENT_PROCESS_ID}
|
||||
|
@ -36,29 +32,20 @@ namespace NzbDrone.App.Test
|
|||
|
||||
Subject.PreventStartIfAlreadyRunning();
|
||||
|
||||
|
||||
Mocker.GetMock<IBrowserService>().Verify(c => c.LaunchWebUI(), Times.Never());
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_enforce_if_another_console_is_running()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(c => c.FindProcessByName(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME))
|
||||
Mocker.GetMock<INzbDroneProcessProvider>()
|
||||
.Setup(c => c.FindNzbDroneProcesses())
|
||||
.Returns(new List<ProcessInfo>
|
||||
{
|
||||
new ProcessInfo{Id = 10}
|
||||
});
|
||||
|
||||
Mocker.GetMock<IProcessProvider>().Setup(c => c.FindProcessByName(ProcessProvider.NZB_DRONE_PROCESS_NAME))
|
||||
.Returns(new List<ProcessInfo>
|
||||
{
|
||||
new ProcessInfo{Id = 10},
|
||||
new ProcessInfo{Id = CURRENT_PROCESS_ID}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Assert.Throws<TerminateApplicationException>(() => Subject.PreventStartIfAlreadyRunning());
|
||||
Mocker.GetMock<IBrowserService>().Verify(c => c.LaunchWebUI(), Times.Once());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
@ -67,22 +54,15 @@ namespace NzbDrone.App.Test
|
|||
[Test]
|
||||
public void should_return_false_if_another_gui_is_running()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(c => c.FindProcessByName(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME))
|
||||
Mocker.GetMock<INzbDroneProcessProvider>()
|
||||
.Setup(c => c.FindNzbDroneProcesses())
|
||||
.Returns(new List<ProcessInfo>
|
||||
{
|
||||
new ProcessInfo{Id = CURRENT_PROCESS_ID}
|
||||
new ProcessInfo{Id = CURRENT_PROCESS_ID},
|
||||
new ProcessInfo{Id = 10}
|
||||
|
||||
});
|
||||
|
||||
Mocker.GetMock<IProcessProvider>().Setup(c => c.FindProcessByName(ProcessProvider.NZB_DRONE_PROCESS_NAME))
|
||||
.Returns(new List<ProcessInfo>
|
||||
{
|
||||
new ProcessInfo{Id = 10}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Assert.Throws<TerminateApplicationException>(() => Subject.PreventStartIfAlreadyRunning());
|
||||
Mocker.GetMock<IBrowserService>().Verify(c => c.LaunchWebUI(), Times.Once());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
|
|
@ -33,7 +33,12 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME) &&
|
||||
serviceProvider.GetStatus(ServiceProvider.NZBDRONE_SERVICE_NAME) == ServiceControllerStatus.StartPending;
|
||||
|
||||
ExecutingApplication = Assembly.GetEntryAssembly().Location;
|
||||
var entry = Assembly.GetEntryAssembly();
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
ExecutingApplication = entry.Location;
|
||||
}
|
||||
}
|
||||
|
||||
static RuntimeInfo()
|
||||
|
|
|
@ -5,6 +5,6 @@ namespace NzbDrone.Common.Processes
|
|||
{
|
||||
public interface INzbDroneProcessProvider
|
||||
{
|
||||
List<ProcessInfo> GetNzbDroneProcesses();
|
||||
List<ProcessInfo> FindNzbDroneProcesses();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace NzbDrone.Host
|
|||
private List<int> GetOtherNzbDroneProcessIds()
|
||||
{
|
||||
var currentId = _processProvider.GetCurrentProcess().Id;
|
||||
var otherProcesses = _nzbDroneProcessProvider.GetNzbDroneProcesses()
|
||||
var otherProcesses = _nzbDroneProcessProvider.FindNzbDroneProcesses()
|
||||
.Select(c => c.Id)
|
||||
.Except(new[] {currentId})
|
||||
.ToList();
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentAssertions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -66,6 +70,7 @@
|
|||
<Compile Include="DiskProviderTests\FreeSpaceFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\IsParentFixture.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServiceFactoryFixture.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
@ -79,6 +84,14 @@
|
|||
<Project>{f2be0fdf-6e47-4827-a420-dd4ef82407f8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
|
||||
<Project>{ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}</Project>
|
||||
<Name>NzbDrone.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Host\NzbDrone.Host.csproj">
|
||||
<Project>{95c11a9e-56ed-456a-8447-2c89c1139266}</Project>
|
||||
<Name>NzbDrone.Host</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Mono\NzbDrone.Mono.csproj">
|
||||
<Project>{15ad7579-a314-4626-b556-663f51d97cd1}</Project>
|
||||
<Name>NzbDrone.Mono</Name>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Mono.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ServiceFactoryFixture : TestBase<ServiceFactory>
|
||||
{
|
||||
[SetUp]
|
||||
public void setup()
|
||||
{
|
||||
Mocker.SetConstant(MainAppContainerBuilder.BuildContainer(new StartupContext()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void event_handlers_should_be_unique()
|
||||
{
|
||||
var handlers = Subject.BuildAll<IHandle<ApplicationShutdownRequested>>()
|
||||
.Select(c => c.GetType().FullName);
|
||||
|
||||
handlers.Should().OnlyHaveUniqueItems();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentAssertions" version="2.1.0.0" targetFramework="net40" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
</packages>
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Mono
|
|||
_processProvider = processProvider;
|
||||
}
|
||||
|
||||
public List<ProcessInfo> GetNzbDroneProcesses()
|
||||
public List<ProcessInfo> FindNzbDroneProcesses()
|
||||
{
|
||||
var monoProcesses = _processProvider.FindProcessByName("mono");
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentAssertions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net40\FluentAssertions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
|
@ -67,6 +71,7 @@
|
|||
<Compile Include="DiskProviderTests\DiskProviderFixture.cs" />
|
||||
<Compile Include="DiskProviderTests\FreeSpaceFixture.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServiceFactoryFixture.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Common.Test\NzbDrone.Common.Test.csproj">
|
||||
|
@ -77,6 +82,14 @@
|
|||
<Project>{f2be0fdf-6e47-4827-a420-dd4ef82407f8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
|
||||
<Project>{ff5ee3b6-913b-47ce-9ceb-11c51b4e1205}</Project>
|
||||
<Name>NzbDrone.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Host\NzbDrone.Host.csproj">
|
||||
<Project>{95c11a9e-56ed-456a-8447-2c89c1139266}</Project>
|
||||
<Name>NzbDrone.Host</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
|
||||
<Project>{caddfce0-7509-4430-8364-2074e1eefca2}</Project>
|
||||
<Name>NzbDrone.Test.Common</Name>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Host;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Windows.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ServiceFactoryFixture : TestBase<ServiceFactory>
|
||||
{
|
||||
[SetUp]
|
||||
public void setup()
|
||||
{
|
||||
Mocker.SetConstant(MainAppContainerBuilder.BuildContainer(new StartupContext()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void event_handlers_should_be_unique()
|
||||
{
|
||||
var handlers = Subject.BuildAll<IHandle<ApplicationShutdownRequested>>()
|
||||
.Select(c => c.GetType().FullName);
|
||||
|
||||
handlers.Should().OnlyHaveUniqueItems();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentAssertions" version="2.1.0.0" targetFramework="net40" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net40" />
|
||||
</packages>
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Windows
|
|||
_processProvider = processProvider;
|
||||
}
|
||||
|
||||
public List<ProcessInfo> GetNzbDroneProcesses()
|
||||
public List<ProcessInfo> FindNzbDroneProcesses()
|
||||
{
|
||||
var consoleProcesses = _processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME);
|
||||
var winformProcesses = _processProvider.FindProcessByName(ProcessProvider.NZB_DRONE_PROCESS_NAME);
|
||||
|
|
|
@ -73,6 +73,9 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platform", "Platform", "{0F0D4998-8F5D-4467-A909-BB192C4B3B4B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platform", "Platform", "{4EACDBBC-BCD7-4765-A57B-3E08331E4749}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
NzbDrone.Common.Test\ServiceFactoryFixture.cs = NzbDrone.Common.Test\ServiceFactoryFixture.cs
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Windows.Test", "NzbDrone.Windows.Test\NzbDrone.Windows.Test.csproj", "{80B51429-7A0E-46D6-BEE3-C80DCB1C4EAA}"
|
||||
EndProject
|
||||
|
|
Loading…
Reference in New Issue