2011-05-22 16:53:21 +00:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
using System;
|
2011-05-20 04:59:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.ServiceModel.Syndication;
|
|
|
|
|
using AutoMoq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using MbUnit.Framework;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Providers.ExternalNotification;
|
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
public class InventoryProviderTest : TestBase
|
|
|
|
|
{
|
2011-05-24 04:12:54 +00:00
|
|
|
|
private EpisodeParseResult parseResultMulti;
|
2011-05-20 05:21:45 +00:00
|
|
|
|
private Series series;
|
|
|
|
|
private Episode episode;
|
2011-05-24 04:12:54 +00:00
|
|
|
|
private Episode episode2;
|
|
|
|
|
private EpisodeParseResult parseResultSingle;
|
2011-05-20 05:21:45 +00:00
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public new void Setup()
|
2011-05-20 04:59:35 +00:00
|
|
|
|
{
|
2011-05-24 04:12:54 +00:00
|
|
|
|
parseResultMulti = new EpisodeParseResult()
|
2011-05-20 05:21:45 +00:00
|
|
|
|
{
|
|
|
|
|
CleanTitle = "Title",
|
|
|
|
|
EpisodeTitle = "EpisodeTitle",
|
|
|
|
|
Language = LanguageType.English,
|
|
|
|
|
Proper = true,
|
2011-05-26 03:13:39 +00:00
|
|
|
|
Quality = QualityTypes.Bluray720p,
|
2011-05-24 04:12:54 +00:00
|
|
|
|
EpisodeNumbers = new List<int> { 3, 4 },
|
2011-05-20 05:21:45 +00:00
|
|
|
|
SeasonNumber = 12,
|
|
|
|
|
AirDate = DateTime.Now.AddDays(-12).Date
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-24 04:12:54 +00:00
|
|
|
|
parseResultSingle = new EpisodeParseResult()
|
|
|
|
|
{
|
|
|
|
|
CleanTitle = "Title",
|
|
|
|
|
EpisodeTitle = "EpisodeTitle",
|
|
|
|
|
Language = LanguageType.English,
|
|
|
|
|
Proper = true,
|
2011-05-26 03:13:39 +00:00
|
|
|
|
Quality = QualityTypes.Bluray720p,
|
2011-05-24 04:12:54 +00:00
|
|
|
|
EpisodeNumbers = new List<int> { 3 },
|
|
|
|
|
SeasonNumber = 12,
|
|
|
|
|
AirDate = DateTime.Now.AddDays(-12).Date
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Monitored = true)
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.With(d => d.CleanTitle = parseResultMulti.CleanTitle)
|
2011-05-20 04:59:35 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
episode = Builder<Episode>.CreateNew()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.With(c => c.EpisodeNumber = parseResultMulti.EpisodeNumbers[0])
|
|
|
|
|
.With(c => c.SeasonNumber = parseResultMulti.SeasonNumber)
|
|
|
|
|
.With(c => c.AirDate = parseResultMulti.AirDate)
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-05-24 04:12:54 +00:00
|
|
|
|
episode2 = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(c => c.EpisodeNumber = parseResultMulti.EpisodeNumbers[1])
|
|
|
|
|
.With(c => c.SeasonNumber = parseResultMulti.SeasonNumber)
|
|
|
|
|
.With(c => c.AirDate = parseResultMulti.AirDate)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
base.Setup();
|
2011-05-20 05:52:05 +00:00
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void not_monitored_series_should_be_skipped()
|
|
|
|
|
{
|
|
|
|
|
series.Monitored = false;
|
|
|
|
|
|
2011-05-20 04:59:35 +00:00
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultMulti);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
2011-05-20 04:59:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void no_db_series_should_be_skipped()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns<Series>(null);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultMulti);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
2011-05-20 04:59:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void unwannted_quality_should_be_skipped()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultMulti.Quality))
|
2011-05-20 04:59:35 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultMulti);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
2011-05-20 04:59:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ignored_season_should_be_skipped()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultMulti.Quality))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeasonProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsIgnored(series.SeriesId, parseResultMulti.SeasonNumber))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultMulti);
|
2011-05-20 05:21:45 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-05-20 04:59:35 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void unwannted_file_should_be_skipped()
|
|
|
|
|
{
|
2011-05-20 05:21:45 +00:00
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns(episode);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
2011-05-24 04:12:54 +00:00
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode2.SeriesId, episode2.SeasonNumber, episode2.EpisodeNumber))
|
|
|
|
|
.Returns(episode2);
|
|
|
|
|
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultMulti.Quality))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(true);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.GetMock<SeasonProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsIgnored(series.SeriesId, parseResultMulti.SeasonNumber))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.IsNeeded(parseResultMulti, episode))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsNeeded(parseResultMulti, episode2))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultMulti);
|
2011-05-20 05:21:45 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 05:52:05 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void file_in_history_should_be_skipped()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns(episode);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultSingle.Quality))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeasonProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsIgnored(series.SeriesId, parseResultSingle.SeasonNumber))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsNeeded(parseResultSingle, episode))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<HistoryProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.Exists(episode.EpisodeId, parseResultSingle.Quality, parseResultSingle.Proper))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultSingle);
|
2011-05-20 05:52:05 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void dailyshow_should_do_daily_lookup()
|
|
|
|
|
{
|
2011-05-20 04:59:35 +00:00
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns<Episode>(null);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.AirDate))
|
2011-05-20 04:59:35 +00:00
|
|
|
|
.Returns(episode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultSingle.Quality))
|
2011-05-20 04:59:35 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeasonProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsIgnored(series.SeriesId, parseResultSingle.SeasonNumber))
|
2011-05-20 04:59:35 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsNeeded(parseResultSingle, episode))
|
2011-05-20 04:59:35 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultSingle);
|
2011-05-20 04:59:35 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
2011-05-20 05:21:45 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void none_db_episode_should_be_added()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultSingle.Quality))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeasonProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsIgnored(series.SeriesId, parseResultSingle.SeasonNumber))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns<Episode>(null);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.AirDate))
|
|
|
|
|
.Returns<Episode>(null);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.AddEpisode(It.IsAny<Episode>()))
|
|
|
|
|
.Returns(12);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsNeeded(parseResultSingle, It.IsAny<Episode>()))
|
2011-05-20 05:21:45 +00:00
|
|
|
|
.Returns(false);
|
2011-05-20 05:52:05 +00:00
|
|
|
|
|
2011-05-20 05:21:45 +00:00
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultSingle);
|
2011-05-20 05:21:45 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsFalse(result);
|
|
|
|
|
mocker.VerifyAllMocks();
|
2011-05-20 04:59:35 +00:00
|
|
|
|
}
|
2011-05-20 05:52:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-05-24 04:12:54 +00:00
|
|
|
|
public void first_file_needed_should_return_true()
|
2011-05-20 05:52:05 +00:00
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns(episode);
|
|
|
|
|
|
2011-05-24 04:12:54 +00:00
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode2.SeriesId, episode2.SeasonNumber, episode2.EpisodeNumber))
|
|
|
|
|
.Returns(episode2);
|
2011-05-20 05:52:05 +00:00
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultMulti.Quality))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeasonProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsIgnored(series.SeriesId, parseResultMulti.SeasonNumber))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.IsNeeded(parseResultMulti, episode))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<HistoryProvider>()
|
|
|
|
|
.Setup(p => p.Exists(episode.EpisodeId, parseResultMulti.Quality, parseResultMulti.Proper))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultMulti);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsTrue(result);
|
|
|
|
|
Assert.Contains(parseResultMulti.Episodes, episode);
|
|
|
|
|
Assert.Contains(parseResultMulti.Episodes, episode2);
|
|
|
|
|
Assert.AreEqual(series, parseResultMulti.Series);
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void second_file_needed_should_return_true()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
|
|
|
|
.Returns(series);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber))
|
|
|
|
|
.Returns(episode);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.GetEpisode(episode2.SeriesId, episode2.SeasonNumber, episode2.EpisodeNumber))
|
|
|
|
|
.Returns(episode2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(p => p.QualityWanted(series.SeriesId, parseResultMulti.Quality))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeasonProvider>()
|
|
|
|
|
.Setup(p => p.IsIgnored(series.SeriesId, parseResultMulti.SeasonNumber))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(p => p.IsNeeded(parseResultMulti, episode))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.IsNeeded(parseResultMulti, episode2))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<HistoryProvider>()
|
2011-05-24 04:12:54 +00:00
|
|
|
|
.Setup(p => p.Exists(episode2.EpisodeId, parseResultMulti.Quality, parseResultMulti.Proper))
|
2011-05-20 05:52:05 +00:00
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-24 04:12:54 +00:00
|
|
|
|
var result = mocker.Resolve<InventoryProvider>().IsNeeded(parseResultMulti);
|
2011-05-20 05:52:05 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsTrue(result);
|
2011-05-24 04:12:54 +00:00
|
|
|
|
Assert.Contains(parseResultMulti.Episodes, episode);
|
|
|
|
|
Assert.Contains(parseResultMulti.Episodes, episode2);
|
|
|
|
|
Assert.AreEqual(series, parseResultMulti.Series);
|
2011-05-20 05:52:05 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
2011-05-20 04:59:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|