Fixed broken unit test

This commit is contained in:
Mark McDowall 2015-07-08 23:58:12 -07:00
parent 15b215f9c2
commit fa0401fa89
1 changed files with 9 additions and 15 deletions

View File

@ -1,38 +1,30 @@
using System.Collections.Generic; using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.History; using NzbDrone.Core.History;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using System.Linq; using System.Linq;
namespace NzbDrone.Core.Test.Download namespace NzbDrone.Core.Test.Download.TrackedDownloads
{ {
[TestFixture] [TestFixture]
public class TrackedDownloadServiceFixture : CoreTest<TrackedDownloadService> public class TrackedDownloadServiceFixture : CoreTest<TrackedDownloadService>
{ {
private void GivenAHistoryWithADownload() private void GivenDownloadHistory()
{ {
Mocker.GetMock<IHistoryService>() Mocker.GetMock<IHistoryService>()
.Setup(s => s.FindByDownloadId(It.Is<string>(sr => sr == "35238"))) .Setup(s => s.FindByDownloadId(It.Is<string>(sr => sr == "35238")))
.Returns(new List<History.History>(){ .Returns(new List<History.History>(){
new History.History(){ new History.History(){
DownloadId = "35238", DownloadId = "35238",
SourceTitle = "Tv Series S01", SourceTitle = "TV Series S01",
SeriesId = 5, SeriesId = 5,
EpisodeId = 4 EpisodeId = 4
} }
@ -42,7 +34,7 @@ namespace NzbDrone.Core.Test.Download
[Test] [Test]
public void should_track_downloads_using_the_source_title_if_it_cannot_be_found_using_the_download_title() public void should_track_downloads_using_the_source_title_if_it_cannot_be_found_using_the_download_title()
{ {
GivenAHistoryWithADownload(); GivenDownloadHistory();
var remoteEpisode = new RemoteEpisode var remoteEpisode = new RemoteEpisode
{ {
@ -50,13 +42,13 @@ namespace NzbDrone.Core.Test.Download
Episodes = new List<Episode> { new Episode { Id = 4 } }, Episodes = new List<Episode> { new Episode { Id = 4 } },
ParsedEpisodeInfo = new ParsedEpisodeInfo() ParsedEpisodeInfo = new ParsedEpisodeInfo()
{ {
SeriesTitle = "tvseries", SeriesTitle = "TV Series",
SeasonNumber = 1 SeasonNumber = 1
} }
}; };
Mocker.GetMock<IParsingService>() Mocker.GetMock<IParsingService>()
.Setup(s => s.Map(It.Is<ParsedEpisodeInfo>(i => i.SeasonNumber == 1 && i.SeriesTitle == "tvseries"), It.IsAny<int>(), It.IsAny<IEnumerable<int>>())) .Setup(s => s.Map(It.Is<ParsedEpisodeInfo>(i => i.SeasonNumber == 1 && i.SeriesTitle == "TV Series"), It.IsAny<int>(), It.IsAny<IEnumerable<int>>()))
.Returns(remoteEpisode); .Returns(remoteEpisode);
var client = new DownloadClientDefinition() var client = new DownloadClientDefinition()
@ -73,10 +65,12 @@ namespace NzbDrone.Core.Test.Download
var trackedDownload = Subject.TrackDownload(client, item); var trackedDownload = Subject.TrackDownload(client, item);
trackedDownload.Should().NotBeNull();
trackedDownload.RemoteEpisode.Should().NotBeNull();
trackedDownload.RemoteEpisode.Series.Should().NotBeNull();
trackedDownload.RemoteEpisode.Series.Id.Should().Be(5); trackedDownload.RemoteEpisode.Series.Id.Should().Be(5);
trackedDownload.RemoteEpisode.Episodes.First().Id.Should().Be(4); trackedDownload.RemoteEpisode.Episodes.First().Id.Should().Be(4);
trackedDownload.RemoteEpisode.ParsedEpisodeInfo.SeasonNumber.Should().Be(1); trackedDownload.RemoteEpisode.ParsedEpisodeInfo.SeasonNumber.Should().Be(1);
trackedDownload.RemoteEpisode.ParsedEpisodeInfo.SeriesTitle.Should().Be("tvseries");
} }
} }
} }