2011-05-22 18:53:21 +02:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
using System;
|
2011-05-20 06:18:51 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
using AutoMoq;
|
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using FluentAssertions;
|
2011-05-20 06:18:51 +02:00
|
|
|
|
using Moq;
|
2011-06-02 23:06:46 +02:00
|
|
|
|
using NUnit.Framework;
|
2011-05-20 06:18:51 +02:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-05-19 05:55:35 +02:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-06-16 08:33:01 +02:00
|
|
|
|
using PetaPoco;
|
2011-05-20 06:18:51 +02:00
|
|
|
|
using SubSonic.Repository;
|
|
|
|
|
using TvdbLib.Data;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-05-19 05:55:35 +02:00
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-05-20 06:18:51 +02:00
|
|
|
|
public class EpisodeProviderTest : TestBase
|
|
|
|
|
{
|
2011-06-16 08:33:01 +02:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisodesBySeason_success()
|
|
|
|
|
{
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(10)
|
|
|
|
|
.WhereAll().Have(c => c.SeriesId = 12)
|
|
|
|
|
.WhereTheFirst(5).Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.AndTheRemaining().Have(c => c.SeasonNumber = 2).Build();
|
|
|
|
|
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var seasonEposodes = mocker.Resolve<EpisodeProvider>().GetEpisodesBySeason(12, 2);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
db.Fetch<Episode>().Should().HaveCount(10);
|
|
|
|
|
seasonEposodes.Should().HaveCount(5);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 06:18:51 +02:00
|
|
|
|
[Test]
|
2011-05-29 05:01:35 +02:00
|
|
|
|
public void RefreshEpisodeInfo_emptyRepo()
|
2011-05-20 06:18:51 +02:00
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
const int seriesId = 71663;
|
|
|
|
|
const int episodeCount = 10;
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<TvdbSeries>.CreateNew().With(
|
|
|
|
|
c => c.Episodes =
|
|
|
|
|
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
|
|
|
|
WhereAll()
|
|
|
|
|
.Have(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
|
|
|
|
.Build())
|
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
|
|
|
|
|
2011-05-29 05:01:35 +02:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
|
2011-05-20 06:18:51 +02:00
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
2011-05-20 06:18:51 +02:00
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>()
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-05-29 05:01:35 +02:00
|
|
|
|
.Returns(fakeEpisodes);
|
2011-05-20 06:18:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-29 05:01:35 +02:00
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
2011-05-20 06:18:51 +02:00
|
|
|
|
//Assert
|
2011-06-05 09:25:50 +02:00
|
|
|
|
var actualCount = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList().Count;
|
2011-05-20 06:18:51 +02:00
|
|
|
|
mocker.GetMock<TvDbProvider>().VerifyAll();
|
2011-06-02 23:06:46 +02:00
|
|
|
|
actualCount.Should().Be(episodeCount);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-06-16 08:33:01 +02:00
|
|
|
|
public void new_episodes_only_calls_Insert()
|
2011-05-29 05:01:35 +02:00
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 05:01:35 +02:00
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(5).Build())
|
2011-05-29 05:37:19 +02:00
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var currentEpisodes = new List<Episode>();
|
|
|
|
|
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 08:33:01 +02:00
|
|
|
|
.Returns(tvdbSeries);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<IDatabase>()
|
|
|
|
|
.Setup(d => d.Fetch<Episode>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
|
|
|
|
.Returns(currentEpisodes);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.Insert(It.IsAny<Object>()), Times.Exactly(tvdbSeries.Episodes.Count));
|
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.Update(It.IsAny<Object>()), Times.Never());
|
|
|
|
|
|
2011-05-29 05:01:35 +02:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-06-16 08:33:01 +02:00
|
|
|
|
public void existing_episodes_only_calls_Update()
|
2011-05-29 05:01:35 +02:00
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 05:01:35 +02:00
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(5).Build())
|
2011-05-29 05:37:19 +02:00
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var currentEpisodes = new List<Episode>();
|
|
|
|
|
foreach (var tvDbEpisode in tvdbSeries.Episodes)
|
|
|
|
|
{
|
|
|
|
|
currentEpisodes.Add(new Episode { TvDbEpisodeId = tvDbEpisode.Id });
|
|
|
|
|
}
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 08:33:01 +02:00
|
|
|
|
.Returns(tvdbSeries);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
|
|
|
|
.Setup(d => d.Fetch<Episode>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
|
|
|
|
.Returns(currentEpisodes);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.Insert(It.IsAny<Object>()), Times.Never());
|
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.Update(It.IsAny<Object>()), Times.Exactly(tvdbSeries.Episodes.Count));
|
2011-05-29 05:01:35 +02:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-05-29 05:37:19 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void should_try_to_get_existing_episode_using_tvdbid_first()
|
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var fakeTvDbResult = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 05:37:19 +02:00
|
|
|
|
.With(c => c.Id = seriesId)
|
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>(
|
|
|
|
|
Builder<TvdbEpisode>.CreateListOfSize(1)
|
|
|
|
|
.WhereAll().Have(g => g.Id = 99)
|
|
|
|
|
.Build())
|
|
|
|
|
)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var fakeEpisodeList = new List<Episode> { new Episode { TvDbEpisodeId = 99, SeasonNumber = 10, EpisodeNumber = 10 } };
|
2011-05-29 05:37:19 +02:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
|
|
|
|
.Setup(d => d.Fetch<Episode>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
|
|
|
|
.Returns(fakeEpisodeList);
|
2011-05-29 05:37:19 +02:00
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<TvDbProvider>()
|
2011-05-29 05:37:19 +02:00
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 08:33:01 +02:00
|
|
|
|
.Returns(fakeTvDbResult);
|
2011-05-29 05:37:19 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.Update(fakeEpisodeList[0]), Times.Once());
|
2011-05-29 05:37:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_try_to_get_existing_episode_using_tvdbid_first_then_season_episode()
|
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 05:37:19 +02:00
|
|
|
|
.With(c => c.Id = seriesId)
|
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>{
|
|
|
|
|
Builder<TvdbEpisode>.CreateNew()
|
|
|
|
|
.With(g => g.Id = 99)
|
|
|
|
|
.With(g => g.SeasonNumber = 4)
|
|
|
|
|
.With(g => g.EpisodeNumber = 15)
|
|
|
|
|
.With(g=>g.SeriesId = seriesId)
|
|
|
|
|
.Build()
|
|
|
|
|
})
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var localEpisode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(c => c.SeriesId = seriesId)
|
|
|
|
|
.With(c => c.SeasonNumber = 4)
|
|
|
|
|
.With(c => c.EpisodeNumber = 15)
|
|
|
|
|
.Build();
|
2011-06-02 23:06:46 +02:00
|
|
|
|
|
2011-05-29 05:37:19 +02:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 08:33:01 +02:00
|
|
|
|
.Returns(tvdbSeries);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<IDatabase>()
|
|
|
|
|
.Setup(d => d.Fetch<Episode>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
|
|
|
|
.Returns(new List<Episode> { localEpisode });
|
2011-05-29 05:37:19 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.Update(localEpisode), Times.Once());
|
2011-05-29 05:37:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-05-29 05:01:35 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void existing_episodes_keep_their_episodeId_file_id()
|
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 05:01:35 +02:00
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(5).Build())
|
2011-05-29 05:37:19 +02:00
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
2011-06-16 08:33:01 +02:00
|
|
|
|
|
|
|
|
|
var currentEpisodes = new List<Episode>();
|
|
|
|
|
foreach (var tvDbEpisode in tvdbSeries.Episodes)
|
|
|
|
|
{
|
|
|
|
|
currentEpisodes.Add(new Episode { TvDbEpisodeId = tvDbEpisode.Id, EpisodeId = 99, EpisodeFileId = 69, Ignored = true });
|
|
|
|
|
}
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 08:33:01 +02:00
|
|
|
|
.Returns(tvdbSeries);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
var updatedEpisodes = new List<Episode>();
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
|
|
|
|
.Setup(d => d.Fetch<Episode>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
|
|
|
|
.Returns(currentEpisodes);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
|
|
|
|
.Setup(c => c.Update(It.IsAny<Episode>()))
|
|
|
|
|
.Returns(1)
|
|
|
|
|
.Callback<Episode>(ep => updatedEpisodes.Add(ep));
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-06-16 08:33:01 +02:00
|
|
|
|
updatedEpisodes.Should().HaveSameCount(tvdbSeries.Episodes);
|
2011-06-02 23:06:46 +02:00
|
|
|
|
updatedEpisodes.Should().OnlyContain(c => c.EpisodeId == 99);
|
|
|
|
|
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 69);
|
2011-06-16 08:33:01 +02:00
|
|
|
|
updatedEpisodes.Should().OnlyContain(c => c.Ignored == true);
|
2011-05-20 06:18:51 +02:00
|
|
|
|
}
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
|
|
|
|
|
2011-06-05 08:24:24 +02:00
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_true_if_all_episodes_ignored()
|
|
|
|
|
{
|
|
|
|
|
var repo = MockLib.GetEmptyRepository();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(repo);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 2)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
repo.AddMany(episodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 2);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_false_if_none_of_episodes_are_ignored()
|
|
|
|
|
{
|
|
|
|
|
var repo = MockLib.GetEmptyRepository();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(repo);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 2)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
repo.AddMany(episodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 2);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_false_if_some_of_episodes_are_ignored()
|
|
|
|
|
{
|
|
|
|
|
var repo = MockLib.GetEmptyRepository();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(repo);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 2)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
episodes[2].Ignored = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
repo.AddMany(episodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 2);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_true_if_invalid_series()
|
|
|
|
|
{
|
|
|
|
|
var repo = MockLib.GetEmptyRepository();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(repo);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 2);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 06:18:51 +02:00
|
|
|
|
[Test]
|
|
|
|
|
[Explicit]
|
|
|
|
|
public void Add_daily_show_episodes()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
2011-06-16 08:33:01 +02:00
|
|
|
|
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
2011-05-20 06:18:51 +02:00
|
|
|
|
mocker.Resolve<TvDbProvider>();
|
|
|
|
|
const int tvDbSeriesId = 71256;
|
|
|
|
|
//act
|
|
|
|
|
var seriesProvider = mocker.Resolve<SeriesProvider>();
|
|
|
|
|
|
|
|
|
|
seriesProvider.AddSeries("c:\\test\\", tvDbSeriesId, 0);
|
2011-05-29 05:01:35 +02:00
|
|
|
|
|
2011-05-20 06:18:51 +02:00
|
|
|
|
var episodeProvider = mocker.Resolve<EpisodeProvider>();
|
2011-05-29 05:01:35 +02:00
|
|
|
|
episodeProvider.RefreshEpisodeInfo(seriesProvider.GetSeries(tvDbSeriesId));
|
2011-05-20 06:18:51 +02:00
|
|
|
|
|
|
|
|
|
//assert
|
|
|
|
|
var episodes = episodeProvider.GetEpisodeBySeries(tvDbSeriesId);
|
2011-06-02 23:06:46 +02:00
|
|
|
|
episodes.Should().NotBeEmpty();
|
2011-05-20 06:18:51 +02:00
|
|
|
|
}
|
2011-06-05 08:24:24 +02:00
|
|
|
|
|
|
|
|
|
|
2011-05-20 06:18:51 +02:00
|
|
|
|
}
|
2011-05-29 05:37:19 +02:00
|
|
|
|
}
|