|
|
|
@ -26,9 +26,18 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
public void processResults_ParseResult_should_return_after_match()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(5)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int>{1})
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
@ -39,7 +48,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
mocker.GetMock<DownloadProvider>()
|
|
|
|
|
.Setup(c => c.DownloadReport(It.IsAny<EpisodeParseResult>())).Returns(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
@ -51,16 +62,24 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_higher_quality_should_be_called_first()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(10)
|
|
|
|
|
.All().With(c => c.Quality = new Quality(QualityTypes.DVD, true))
|
|
|
|
|
.Random(1).With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
|
|
|
|
|
.Random(1)
|
|
|
|
|
.With(c => c.Quality = new Quality(QualityTypes.Bluray1080p, true))
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
@ -76,6 +95,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
c.DownloadReport(It.Is<EpisodeParseResult>(d => d.Quality.QualityType == QualityTypes.Bluray1080p)))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
@ -87,18 +109,26 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_when_same_quality_proper_should_be_called_first()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(20)
|
|
|
|
|
.All().With(c => c.Quality = new Quality(QualityTypes.DVD, false))
|
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Random(1).With(c => c.Quality = new Quality(QualityTypes.DVD, true))
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
parseResults.Where(c => c.Quality.Proper).Should().HaveCount(1);
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
@ -108,6 +138,8 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
mocker.GetMock<DownloadProvider>()
|
|
|
|
|
.Setup(c => c.DownloadReport(It.Is<EpisodeParseResult>(p => p.Quality.Proper))).Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
@ -120,20 +152,31 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
Times.Once());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_when_not_needed_should_check_the_rest()
|
|
|
|
|
public void processResults_when_quality_is_not_needed_should_check_the_rest()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<InventoryProvider>()
|
|
|
|
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
@ -144,20 +187,31 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_failed_IsNeeded_should_check_the_rest()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<InventoryProvider>()
|
|
|
|
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Throws(new Exception());
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
@ -173,9 +227,18 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
public void processResults_failed_download_should_not_check_the_rest()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew().Build();
|
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
@ -185,6 +248,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
mocker.GetMock<DownloadProvider>()
|
|
|
|
|
.Setup(c => c.DownloadReport(It.IsAny<EpisodeParseResult>())).Throws(new Exception());
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
@ -205,8 +271,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
|
|
|
|
.With(c => c.Series = series)
|
|
|
|
|
.With(c => c.SeasonNumber = 12)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
@ -216,6 +285,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
|
|
|
|
.Returns(episode);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
var indexer1 = new Mock<IndexerBase>();
|
|
|
|
|
indexer1.Setup(c => c.FetchEpisode(episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns(parseResults).Verifiable();
|
|
|
|
@ -234,9 +306,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
|
|
|
|
.Returns(episode.Series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<InventoryProvider>()
|
|
|
|
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SceneMappingProvider>()
|
|
|
|
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
|
|
|
|
|
|
|
|
@ -246,8 +315,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Exactly(8));
|
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
indexer1.VerifyAll();
|
|
|
|
|
indexer2.VerifyAll();
|
|
|
|
@ -259,8 +327,11 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew().With(s => s.SeriesId = 71256)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(c => c.Series = Builder<Series>.CreateNew().With(s => s.SeriesId = 71256).Build())
|
|
|
|
|
.With(c => c.Series = series)
|
|
|
|
|
.With(c => c.SeasonNumber = 12)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
@ -270,6 +341,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
|
|
|
|
.Returns(episode);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
var indexer1 = new Mock<IndexerBase>();
|
|
|
|
|
indexer1.Setup(c => c.FetchEpisode("The Daily Show", episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns(parseResults).Verifiable();
|
|
|
|
@ -288,20 +362,14 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
|
|
|
|
.Returns(episode.Series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<InventoryProvider>()
|
|
|
|
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SceneMappingProvider>()
|
|
|
|
|
.Setup(s => s.GetSceneName(71256)).Returns("The Daily Show");
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<SearchProvider>().EpisodeSearch(new ProgressNotification("Test"), episode.EpisodeId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Exactly(8));
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
indexer1.VerifyAll();
|
|
|
|
|
indexer2.VerifyAll();
|
|
|
|
@ -348,9 +416,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
.Setup(c => c.GetSeries(It.IsAny<int>()))
|
|
|
|
|
.Returns(episode.Series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<InventoryProvider>()
|
|
|
|
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SceneMappingProvider>()
|
|
|
|
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
|
|
|
|
|
|
|
|
@ -360,8 +425,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
mocker.GetMock<InventoryProvider>().Verify(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>()),
|
|
|
|
|
Times.Exactly(8));
|
|
|
|
|
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
ExceptionVerification.ExcpectedErrors(1);
|
|
|
|
@ -394,8 +457,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(4)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew().Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
|
|
|
|
.With(c => c.Series = series)
|
|
|
|
|
.With(c => c.SeasonNumber = 12)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
@ -405,6 +470,9 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
.Setup(c => c.GetEpisode(episode.EpisodeId))
|
|
|
|
|
.Returns(episode);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
var indexer1 = new Mock<IndexerBase>();
|
|
|
|
|
indexer1.Setup(c => c.FetchEpisode(episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns(parseResults).Verifiable();
|
|
|
|
@ -415,9 +483,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
.Setup(c => c.GetEnabledIndexers())
|
|
|
|
|
.Returns(indexers);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<InventoryProvider>()
|
|
|
|
|
.Setup(c => c.IsQualityNeeded(It.IsAny<EpisodeParseResult>())).Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SceneMappingProvider>()
|
|
|
|
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
|
|
|
|
|
|
|
|
@ -433,5 +498,134 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
indexer1.VerifyAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_should_return_false_when_series_is_null()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Series series = null;
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_should_return_false_when_seriesId_doesnt_match()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 100)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = 1)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_should_return_false_when_seasonNumber_doesnt_match()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 100)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 2)
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void processResults_should_return_false_when_episodeNumber_doesnt_match()
|
|
|
|
|
{
|
|
|
|
|
var parseResults = Builder<EpisodeParseResult>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumbers = new List<int> { 1 })
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 100)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = series.SeriesId)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 2)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<SearchProvider>().ProcessEpisodeSearchResults(new ProgressNotification("Test"), episode, parseResults);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
ExceptionVerification.ExcpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|