Fixed broken tests

pull/2/head
Mark McDowall 11 years ago
parent 8520fe3e0c
commit 5150f9bd91

@ -8,24 +8,18 @@ using NzbDrone.Core.Download;
using NzbDrone.Core.History; using NzbDrone.Core.History;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Download namespace NzbDrone.Core.Test.Download
{ {
[TestFixture] [TestFixture]
public class FailedDownloadServiceFixture : CoreTest<FailedDownloadService> public class FailedDownloadServiceFixture : CoreTest<FailedDownloadService>
{ {
private Series _series;
private Episode _episode;
private List<HistoryItem> _completed; private List<HistoryItem> _completed;
private List<HistoryItem> _failed; private List<HistoryItem> _failed;
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
_series = Builder<Series>.CreateNew().Build();
_episode = Builder<Episode>.CreateNew().Build();
_completed = Builder<HistoryItem>.CreateListOfSize(5) _completed = Builder<HistoryItem>.CreateListOfSize(5)
.All() .All()
.With(h => h.Status = HistoryStatus.Completed) .With(h => h.Status = HistoryStatus.Completed)
@ -42,17 +36,17 @@ namespace NzbDrone.Core.Test.Download
.Setup(c => c.GetDownloadClient()).Returns(Mocker.GetMock<IDownloadClient>().Object); .Setup(c => c.GetDownloadClient()).Returns(Mocker.GetMock<IDownloadClient>().Object);
} }
private void GivenNoRecentHistory() private void GivenNoGrabbedHistory()
{ {
Mocker.GetMock<IHistoryService>() Mocker.GetMock<IHistoryService>()
.Setup(s => s.BetweenDates(It.IsAny<DateTime>(), It.IsAny<DateTime>(), HistoryEventType.Grabbed)) .Setup(s => s.Grabbed())
.Returns(new List<History.History>()); .Returns(new List<History.History>());
} }
private void GivenRecentHistory(List<History.History> history) private void GivenGrabbedHistory(List<History.History> history)
{ {
Mocker.GetMock<IHistoryService>() Mocker.GetMock<IHistoryService>()
.Setup(s => s.BetweenDates(It.IsAny<DateTime>(), It.IsAny<DateTime>(), HistoryEventType.Grabbed)) .Setup(s => s.Grabbed())
.Returns(history); .Returns(history);
} }
@ -86,7 +80,7 @@ namespace NzbDrone.Core.Test.Download
private void VerifyFailedDownloads(int count = 1) private void VerifyFailedDownloads(int count = 1)
{ {
Mocker.GetMock<IEventAggregator>() Mocker.GetMock<IEventAggregator>()
.Verify(v => v.PublishEvent(It.IsAny<DownloadFailedEvent>()), Times.Exactly(count)); .Verify(v => v.PublishEvent(It.Is<DownloadFailedEvent>(d => d.EpisodeIds.Count == count)), Times.Once());
} }
[Test] [Test]
@ -124,7 +118,7 @@ namespace NzbDrone.Core.Test.Download
[Test] [Test]
public void should_not_process_if_matching_history_is_not_found() public void should_not_process_if_matching_history_is_not_found()
{ {
GivenNoRecentHistory(); GivenNoGrabbedHistory();
GivenFailedDownloadClientHistory(); GivenFailedDownloadClientHistory();
Subject.Execute(new FailedDownloadCommand()); Subject.Execute(new FailedDownloadCommand());
@ -141,7 +135,7 @@ namespace NzbDrone.Core.Test.Download
.Build() .Build()
.ToList(); .ToList();
GivenRecentHistory(history); GivenGrabbedHistory(history);
GivenFailedHistory(history); GivenFailedHistory(history);
history.First().Data.Add("downloadClient", "SabnzbdClient"); history.First().Data.Add("downloadClient", "SabnzbdClient");
@ -161,7 +155,7 @@ namespace NzbDrone.Core.Test.Download
.Build() .Build()
.ToList(); .ToList();
GivenRecentHistory(history); GivenGrabbedHistory(history);
GivenNoFailedHistory(); GivenNoFailedHistory();
history.First().Data.Add("downloadClient", "SabnzbdClient"); history.First().Data.Add("downloadClient", "SabnzbdClient");
@ -173,7 +167,7 @@ namespace NzbDrone.Core.Test.Download
} }
[Test] [Test]
public void should_process_for_each_failed_episode() public void should_have_multiple_episode_ids_when_multi_episode_release_fails()
{ {
GivenFailedDownloadClientHistory(); GivenFailedDownloadClientHistory();
@ -181,7 +175,7 @@ namespace NzbDrone.Core.Test.Download
.Build() .Build()
.ToList(); .ToList();
GivenRecentHistory(history); GivenGrabbedHistory(history);
GivenNoFailedHistory(); GivenNoFailedHistory();
history.ForEach(h => history.ForEach(h =>

Loading…
Cancel
Save