1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02:00
Sonarr/NzbDrone.Update.Test/UpdateProviderStartTest.cs

56 lines
1.6 KiB
C#
Raw Normal View History

using AutoMoq;
2011-10-23 21:31:17 +03:00
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
2011-10-23 21:31:17 +03:00
using NzbDrone.Common.Model;
using NzbDrone.Update.Providers;
namespace NzbDrone.Update.Test
{
[TestFixture]
2011-10-23 21:31:17 +03:00
class UpdateProviderStartTest
{
AutoMoqer mocker = new AutoMoqer();
[SetUp]
public void Setup()
{
mocker = new AutoMoqer();
}
[Test]
2011-10-23 21:31:17 +03:00
public void should_stop_nzbdrone_service_if_installed()
{
2011-10-23 21:31:17 +03:00
mocker.GetMock<ServiceProvider>()
.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
2011-10-23 21:31:17 +03:00
.Returns(true);
//Act
2011-10-23 21:31:17 +03:00
mocker.Resolve<UpdateProvider>().Start(null);
//Assert
mocker.GetMock<ServiceProvider>().Verify(c => c.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
mocker.VerifyAllMocks();
}
[Test]
2011-10-23 21:31:17 +03:00
public void should_kill_nzbdrone_process_if_running()
{
2011-10-23 21:31:17 +03:00
var proccesses = Builder<ProcessInfo>.CreateListOfSize(2).Build();
mocker.GetMock<ProcessProvider>()
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProccessName))
.Returns(proccesses);
//Act
2011-10-23 21:31:17 +03:00
mocker.Resolve<UpdateProvider>().Start(null);
//Assert
2011-10-23 21:31:17 +03:00
mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[0].Id), Times.Once());
mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[1].Id), Times.Once());
mocker.VerifyAllMocks();
}
}
}