sonarr-repo-only/NzbDrone.Update.Test/UpdateProviderStartTest.cs

60 lines
1.7 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMoq;
2011-10-23 18:31:17 +00:00
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
2011-10-23 18:31:17 +00:00
using NzbDrone.Common.Model;
using NzbDrone.Update.Providers;
namespace NzbDrone.Update.Test
{
[TestFixture]
2011-10-23 18:31:17 +00:00
class UpdateProviderStartTest
{
AutoMoqer mocker = new AutoMoqer();
[SetUp]
public void Setup()
{
mocker = new AutoMoqer();
}
[Test]
2011-10-23 18:31:17 +00:00
public void should_stop_nzbdrone_service_if_installed()
{
2011-10-23 18:31:17 +00:00
mocker.GetMock<ServiceProvider>()
.Setup(c => c.ServiceExist(ServiceProvider.NzbDroneServiceName))
.Returns(true);
//Act
2011-10-23 18:31:17 +00:00
mocker.Resolve<UpdateProvider>().Start(null);
//Assert
2011-10-23 18:31:17 +00:00
mocker.GetMock<ServiceProvider>().Verify(c => c.Stop(ServiceProvider.NzbDroneServiceName), Times.Once());
mocker.VerifyAllMocks();
}
[Test]
2011-10-23 18:31:17 +00:00
public void should_kill_nzbdrone_process_if_running()
{
2011-10-23 18:31:17 +00:00
var proccesses = Builder<ProcessInfo>.CreateListOfSize(2).Build();
mocker.GetMock<ProcessProvider>()
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProccessName))
.Returns(proccesses);
//Act
2011-10-23 18:31:17 +00:00
mocker.Resolve<UpdateProvider>().Start(null);
//Assert
2011-10-23 18:31:17 +00: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();
}
}
}