2011-05-22 16:53:21 +00:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
using System;
|
2011-05-20 04:18:51 +00:00
|
|
|
|
using System.Collections.Generic;
|
2011-06-18 02:00:44 +00:00
|
|
|
|
using System.Linq;
|
2011-05-20 04:18:51 +00:00
|
|
|
|
using AutoMoq;
|
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-02 21:06:46 +00:00
|
|
|
|
using FluentAssertions;
|
2011-05-20 04:18:51 +00:00
|
|
|
|
using Moq;
|
2011-06-02 21:06:46 +00:00
|
|
|
|
using NUnit.Framework;
|
2011-10-12 03:44:19 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
2011-05-20 04:18:51 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-06-21 06:34:45 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-05-20 04:18:51 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-06-21 06:34:45 +00:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2011-05-19 03:55:35 +00:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-06-16 06:33:01 +00:00
|
|
|
|
using PetaPoco;
|
2011-05-20 04:18:51 +00:00
|
|
|
|
using TvdbLib.Data;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-05-19 03:55:35 +00:00
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-05-20 04:18:51 +00:00
|
|
|
|
public class EpisodeProviderTest : TestBase
|
|
|
|
|
{
|
2011-06-19 05:57:24 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisodes_exists()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
2011-06-20 07:40:45 +00:00
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 1).Have(e => e.EpisodeFileId = 0).Build();
|
2011-06-19 05:57:24 +00:00
|
|
|
|
|
2011-09-04 09:20:49 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-19 05:57:24 +00:00
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-06-20 01:46:32 +00:00
|
|
|
|
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
2011-09-28 17:56:30 +00:00
|
|
|
|
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-19 05:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:25:24 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisodes_by_season_episode_exists()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
2011-09-04 09:20:49 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 1)
|
|
|
|
|
.Build();
|
2011-06-20 03:25:24 +00:00
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateNew()
|
2011-09-04 09:20:49 +00:00
|
|
|
|
.With(e => e.SeriesId = 1)
|
2011-06-20 03:25:24 +00:00
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
2011-06-20 07:40:45 +00:00
|
|
|
|
.And(e => e.SeasonNumber = 2)
|
|
|
|
|
.With(e => e.EpisodeFileId = 0).Build();
|
2011-06-20 03:25:24 +00:00
|
|
|
|
|
2011-09-04 09:20:49 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-20 03:25:24 +00:00
|
|
|
|
db.Insert(fakeEpisodes);
|
2011-09-04 09:20:49 +00:00
|
|
|
|
|
2011-06-20 03:25:24 +00:00
|
|
|
|
//Act
|
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(fakeSeries.SeriesId, 2, 1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes);
|
2011-09-28 17:56:30 +00:00
|
|
|
|
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-20 03:25:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisodes_by_season_episode_doesnt_exists()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
2011-06-21 06:34:45 +00:00
|
|
|
|
|
2011-06-20 03:25:24 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.Should().BeNull();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 01:46:32 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisode_with_EpisodeFile()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 1).WhereTheFirst(1).Have(e => e.EpisodeFileId = 1).Have(e => e.EpisodeFile = fakeFile).Build();
|
2011-06-21 06:34:45 +00:00
|
|
|
|
|
2011-09-04 09:20:49 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
db.Insert(fakeFile);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
2011-09-28 17:56:30 +00:00
|
|
|
|
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
episode.EpisodeFile.Should().NotBeNull();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 05:57:24 +00:00
|
|
|
|
[Test]
|
|
|
|
|
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
|
|
|
|
|
public void GetEpisodes_invalid_series()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
mocker.Resolve<SeriesProvider>();
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 1).Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void AttachSeries_empty_list()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().AttachSeries(new List<Episode>());
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().HaveCount(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void AttachSeries_list_success()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(s => s.SeriesId = 12).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 12).Build();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(c => c.GetSeries(12))
|
|
|
|
|
.Returns(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
|
|
|
|
|
fakeEpisodes.Should().OnlyContain(e => e.Series == null);
|
|
|
|
|
var returnedSeries = mocker.Resolve<EpisodeProvider>().AttachSeries(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
fakeEpisodes.Should().OnlyContain(e => e.Series == fakeSeries);
|
|
|
|
|
returnedSeries.Should().BeEquivalentTo(fakeEpisodes);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:25:24 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void AttachSeries_null_episode_should_return_null()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
Episode episode = null;
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().AttachSeries(episode);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeNull();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 05:57:24 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void AttachSeries_single_success()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(s => s.SeriesId = 12).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateNew().With(e => e.SeriesId = 12).Build();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>()
|
|
|
|
|
.Setup(c => c.GetSeries(12))
|
|
|
|
|
.Returns(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var returnedEpisode = mocker.Resolve<EpisodeProvider>().AttachSeries(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
fakeEpisodes.Series.Should().Be(fakeSeries);
|
|
|
|
|
returnedEpisode.Should().Be(fakeEpisodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
|
|
|
|
|
public void AttachSeries_single_invalid_series()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
|
|
|
|
mocker.Resolve<SeriesProvider>();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateNew().With(e => e.SeriesId = 12).Build();
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var returnedEpisode = mocker.Resolve<EpisodeProvider>().AttachSeries(fakeEpisodes);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisodesBySeason_success()
|
|
|
|
|
{
|
2011-09-05 02:56:45 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 12)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2011-09-05 02:56:45 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
|
|
|
|
db.InsertMany(episodes);
|
2011-06-16 06:33:01 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var seasonEposodes = mocker.Resolve<EpisodeProvider>().GetEpisodesBySeason(12, 2);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
db.Fetch<Episode>().Should().HaveCount(10);
|
|
|
|
|
seasonEposodes.Should().HaveCount(5);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 04:18:51 +00:00
|
|
|
|
[Test]
|
2011-05-29 03:01:35 +00:00
|
|
|
|
public void RefreshEpisodeInfo_emptyRepo()
|
2011-05-20 04:18:51 +00: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 03:01:35 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
|
2011-05-20 04:18:51 +00:00
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-09-05 02:56:45 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
db.Insert(fakeSeries);
|
2011-05-20 04:18:51 +00:00
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>()
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-05-29 03:01:35 +00:00
|
|
|
|
.Returns(fakeEpisodes);
|
2011-05-20 04:18:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-05-29 03:01:35 +00:00
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
2011-05-20 04:18:51 +00:00
|
|
|
|
//Assert
|
2011-06-05 07:25:50 +00:00
|
|
|
|
var actualCount = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList().Count;
|
2011-05-20 04:18:51 +00:00
|
|
|
|
mocker.GetMock<TvDbProvider>().VerifyAll();
|
2011-06-02 21:06:46 +00:00
|
|
|
|
actualCount.Should().Be(episodeCount);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 06:56:17 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
const int seriesId = 71663;
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<TvdbSeries>.CreateNew().With(
|
|
|
|
|
c => c.Episodes =
|
|
|
|
|
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(10).
|
|
|
|
|
WhereAll()
|
|
|
|
|
.Have(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
|
|
|
|
.WhereTheFirst(7).Have(e => e.FirstAired = new DateTime(1800, 1, 1))
|
|
|
|
|
.AndTheRemaining().Have(e => e.FirstAired = DateTime.Now)
|
|
|
|
|
.Build())
|
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
2011-09-05 02:56:45 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-23 06:56:17 +00:00
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>()
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
|
|
|
|
.Returns(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var storedEpisodes = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
|
|
|
|
storedEpisodes.Should().HaveCount(10);
|
|
|
|
|
storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(7);
|
|
|
|
|
storedEpisodes.Where(e => e.AirDate != null).Should().HaveCount(3);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-04 02:01:39 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void RefreshEpisodeInfo_ignore_episode_zero()
|
|
|
|
|
{
|
|
|
|
|
//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"))
|
|
|
|
|
.WhereTheFirst(1)
|
|
|
|
|
.Has(e => e.EpisodeNumber = 0)
|
|
|
|
|
.Has(e => e.SeasonNumber = 15)
|
|
|
|
|
.Build())
|
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
db.Insert(fakeSeries);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>()
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
|
|
|
|
.Returns(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
|
|
|
|
mocker.GetMock<TvDbProvider>().VerifyAll();
|
|
|
|
|
result.Should().HaveCount(episodeCount);
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
result.Where(e => e.EpisodeNumber == 0 && e.SeasonNumber == 15).Single().Ignored.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 03:01:35 +00:00
|
|
|
|
[Test]
|
2011-06-16 06:33:01 +00:00
|
|
|
|
public void new_episodes_only_calls_Insert()
|
2011-05-29 03:01:35 +00:00
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 03:01:35 +00:00
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(5).Build())
|
2011-05-29 03:37:19 +00:00
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var currentEpisodes = new List<Episode>();
|
|
|
|
|
|
2011-05-29 03:01:35 +00:00
|
|
|
|
var mocker = new AutoMoqer();
|
2011-07-23 00:57:52 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(tvdbSeries);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<IDatabase>()
|
2011-09-05 02:56:45 +00:00
|
|
|
|
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(currentEpisodes);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-08-31 23:56:25 +00:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.InsertMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 5)), Times.Once());
|
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.Update(It.IsAny<IEnumerable<Episode>>()), Times.Never());
|
2011-06-16 06:33:01 +00:00
|
|
|
|
|
2011-05-29 03:01:35 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-06-16 06:33:01 +00:00
|
|
|
|
public void existing_episodes_only_calls_Update()
|
2011-05-29 03:01:35 +00:00
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 03:01:35 +00:00
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(5).Build())
|
2011-05-29 03:37:19 +00:00
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var currentEpisodes = new List<Episode>();
|
|
|
|
|
foreach (var tvDbEpisode in tvdbSeries.Episodes)
|
|
|
|
|
{
|
2011-09-05 02:56:45 +00:00
|
|
|
|
currentEpisodes.Add(new Episode { TvDbEpisodeId = tvDbEpisode.Id, Series = fakeSeries });
|
2011-06-16 06:33:01 +00:00
|
|
|
|
}
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(tvdbSeries);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
2011-09-05 02:56:45 +00:00
|
|
|
|
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(currentEpisodes);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-08-29 03:03:40 +00:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.InsertMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 0)), Times.Once());
|
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 5)), Times.Once());
|
2011-05-29 03:01:35 +00:00
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 03:37:19 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void should_try_to_get_existing_episode_using_tvdbid_first()
|
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var fakeTvDbResult = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 03:37:19 +00: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();
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
2011-09-05 02:56:45 +00:00
|
|
|
|
var fakeEpisodeList = new List<Episode> { new Episode { TvDbEpisodeId = 99, SeasonNumber = 10, EpisodeNumber = 10, Series = fakeSeries} };
|
|
|
|
|
|
2011-05-29 03:37:19 +00:00
|
|
|
|
var mocker = new AutoMoqer();
|
2011-06-16 06:33:01 +00:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
2011-09-05 02:56:45 +00:00
|
|
|
|
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(fakeEpisodeList);
|
2011-05-29 03:37:19 +00:00
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
mocker.GetMock<TvDbProvider>()
|
2011-05-29 03:37:19 +00:00
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(fakeTvDbResult);
|
2011-05-29 03:37:19 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
2011-08-31 23:56:25 +00:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(fakeEpisodeList), Times.Once());
|
2011-05-29 03:37:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_try_to_get_existing_episode_using_tvdbid_first_then_season_episode()
|
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 03:37:19 +00: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 21:06:46 +00:00
|
|
|
|
|
2011-05-29 03:37:19 +00: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 06:33:01 +00:00
|
|
|
|
.Returns(tvdbSeries);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<IDatabase>()
|
2011-09-05 02:56:45 +00:00
|
|
|
|
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(new List<Episode> { localEpisode });
|
2011-05-29 03:37:19 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
mocker.VerifyAllMocks();
|
2011-08-31 23:56:25 +00:00
|
|
|
|
mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(new List<Episode>{localEpisode}), Times.Once());
|
2011-05-29 03:37:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 03:01:35 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void existing_episodes_keep_their_episodeId_file_id()
|
|
|
|
|
{
|
|
|
|
|
const int seriesId = 71663;
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var tvdbSeries = Builder<TvdbSeries>.CreateNew()
|
2011-05-29 03:01:35 +00:00
|
|
|
|
.With(c => c.Episodes = new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(5).Build())
|
2011-05-29 03:37:19 +00:00
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
2011-06-16 06:33:01 +00:00
|
|
|
|
|
|
|
|
|
var currentEpisodes = new List<Episode>();
|
|
|
|
|
foreach (var tvDbEpisode in tvdbSeries.Episodes)
|
|
|
|
|
{
|
2011-09-05 02:56:45 +00:00
|
|
|
|
currentEpisodes.Add(new Episode { TvDbEpisodeId = tvDbEpisode.Id, EpisodeId = 99, EpisodeFileId = 69, Ignored = true, Series = fakeSeries});
|
2011-06-16 06:33:01 +00:00
|
|
|
|
}
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<TvDbProvider>(MockBehavior.Strict)
|
|
|
|
|
.Setup(c => c.GetSeries(seriesId, true))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(tvdbSeries);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
var updatedEpisodes = new List<Episode>();
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
2011-09-05 02:56:45 +00:00
|
|
|
|
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
|
2011-06-16 06:33:01 +00:00
|
|
|
|
.Returns(currentEpisodes);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
2011-06-16 06:33:01 +00:00
|
|
|
|
mocker.GetMock<IDatabase>()
|
2011-08-29 03:03:40 +00:00
|
|
|
|
.Setup(c => c.UpdateMany(It.IsAny<IEnumerable<Episode>>()))
|
|
|
|
|
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes =ep.ToList());
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-06-16 06:33:01 +00:00
|
|
|
|
updatedEpisodes.Should().HaveSameCount(tvdbSeries.Episodes);
|
2011-06-02 21:06:46 +00:00
|
|
|
|
updatedEpisodes.Should().OnlyContain(c => c.EpisodeId == 99);
|
|
|
|
|
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 69);
|
2011-06-16 06:33:01 +00:00
|
|
|
|
updatedEpisodes.Should().OnlyContain(c => c.Ignored == true);
|
2011-05-20 04:18:51 +00:00
|
|
|
|
}
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
2011-06-05 06:24:24 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_true_if_all_episodes_ignored()
|
|
|
|
|
{
|
2011-06-16 07:00:55 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
2011-06-05 06:24:24 +00:00
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
2011-06-16 07:00:55 +00:00
|
|
|
|
mocker.SetConstant(db);
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 2)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-06-16 07:00:55 +00:00
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
|
|
|
|
//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()
|
|
|
|
|
{
|
2011-06-16 07:00:55 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
2011-06-05 06:24:24 +00:00
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
2011-06-16 07:00:55 +00:00
|
|
|
|
mocker.SetConstant(db);
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 2)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-06-16 07:00:55 +00:00
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
2011-06-19 05:57:24 +00:00
|
|
|
|
|
2011-06-05 06:24:24 +00:00
|
|
|
|
//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()
|
|
|
|
|
{
|
2011-06-16 07:00:55 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
2011-06-05 06:24:24 +00:00
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
2011-06-16 07:00:55 +00:00
|
|
|
|
mocker.SetConstant(db);
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
2011-06-16 07:00:55 +00:00
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 2);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-07-23 00:57:52 +00:00
|
|
|
|
public void IsSeasonIgnored_should_return_false_if_zero_episodes_in_db_for_season()
|
2011-06-05 06:24:24 +00:00
|
|
|
|
{
|
2011-06-16 07:00:55 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
2011-06-05 06:24:24 +00:00
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
2011-06-16 07:00:55 +00:00
|
|
|
|
mocker.SetConstant(db);
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
2011-07-23 00:57:52 +00:00
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 3)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
|
|
|
|
|
2011-06-05 06:24:24 +00:00
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 2);
|
|
|
|
|
|
2011-07-23 00:57:52 +00:00
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_true_if_zero_episodes_in_db_for_season_and_previous_is_ignored()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 3)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 4);
|
|
|
|
|
|
2011-06-05 06:24:24 +00:00
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-23 00:57:52 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_false_if_zero_episodes_in_db_for_season_and_previous_is_not_ignored()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 3)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 4);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_false_if_zero_episodes_in_db_for_season_one()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_true_if_zero_episodes_in_db_for_season_zero()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 0);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsSeasonIgnored_should_return_false_if_season_zero_is_not_ignored()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 0)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
episodes.ToList().ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsIgnored(10, 0);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 04:18:51 +00:00
|
|
|
|
[Test]
|
|
|
|
|
[Explicit]
|
|
|
|
|
public void Add_daily_show_episodes()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
2011-06-21 06:34:45 +00:00
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
2011-05-20 04:18:51 +00:00
|
|
|
|
mocker.Resolve<TvDbProvider>();
|
2011-06-21 06:34:45 +00:00
|
|
|
|
|
|
|
|
|
mocker.GetMock<ConfigProvider>()
|
|
|
|
|
.Setup(e => e.DefaultQualityProfile).Returns(1);
|
|
|
|
|
|
|
|
|
|
db.Insert(Builder<QualityProfile>.CreateNew().Build());
|
|
|
|
|
|
|
|
|
|
|
2011-05-20 04:18:51 +00:00
|
|
|
|
const int tvDbSeriesId = 71256;
|
|
|
|
|
//act
|
|
|
|
|
var seriesProvider = mocker.Resolve<SeriesProvider>();
|
|
|
|
|
|
2011-06-21 06:34:45 +00:00
|
|
|
|
seriesProvider.AddSeries("c:\\test\\", tvDbSeriesId, 1);
|
2011-05-29 03:01:35 +00:00
|
|
|
|
|
2011-05-20 04:18:51 +00:00
|
|
|
|
var episodeProvider = mocker.Resolve<EpisodeProvider>();
|
2011-05-29 03:01:35 +00:00
|
|
|
|
episodeProvider.RefreshEpisodeInfo(seriesProvider.GetSeries(tvDbSeriesId));
|
2011-05-20 04:18:51 +00:00
|
|
|
|
|
|
|
|
|
//assert
|
|
|
|
|
var episodes = episodeProvider.GetEpisodeBySeries(tvDbSeriesId);
|
2011-06-02 21:06:46 +00:00
|
|
|
|
episodes.Should().NotBeEmpty();
|
2011-05-20 04:18:51 +00:00
|
|
|
|
}
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
2011-06-22 01:12:20 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisode_by_Season_Episode_none_existing()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
2011-06-23 06:56:17 +00:00
|
|
|
|
|
2011-06-22 01:12:20 +00:00
|
|
|
|
//Act
|
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.Should().BeNull();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 01:46:32 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisode_by_Season_Episode_with_EpisodeFile()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 1).WhereTheFirst(1).Have(e => e.EpisodeFileId = 1).Have(e => e.EpisodeFile = fakeFile).Build();
|
|
|
|
|
|
2011-09-04 09:20:49 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
db.Insert(fakeFile);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
2011-09-28 17:56:30 +00:00
|
|
|
|
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
episode.EpisodeFile.Should().NotBeNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisode_by_Season_Episode_without_EpisodeFile()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 1).WhereTheFirst(1).Have(e => e.EpisodeFileId = 0).Build();
|
|
|
|
|
|
2011-09-04 09:20:49 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
|
2011-09-28 17:56:30 +00:00
|
|
|
|
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
episode.EpisodeFile.Should().BeNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisode_by_AirDate_with_EpisodeFile()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 1).WhereTheFirst(1).Have(e => e.EpisodeFileId = 1).Have(e => e.EpisodeFile = fakeFile).Build();
|
|
|
|
|
|
2011-09-04 09:20:49 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
db.Insert(fakeFile);
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
2011-06-20 01:46:32 +00:00
|
|
|
|
//Act
|
2011-06-23 06:56:17 +00:00
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
2011-09-28 17:56:30 +00:00
|
|
|
|
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
episode.EpisodeFile.Should().NotBeNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisode_by_AirDate_without_EpisodeFile()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
2011-06-05 06:24:24 +00:00
|
|
|
|
|
2011-06-20 01:46:32 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.SeriesId = 1).WhereTheFirst(1).Have(e => e.EpisodeFileId = 0).Build();
|
|
|
|
|
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
2011-09-04 09:20:49 +00:00
|
|
|
|
db.Insert(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-06-23 06:56:17 +00:00
|
|
|
|
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
|
2011-09-28 17:56:30 +00:00
|
|
|
|
episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-20 01:46:32 +00:00
|
|
|
|
episode.EpisodeFile.Should().BeNull();
|
|
|
|
|
}
|
2011-06-22 01:12:20 +00:00
|
|
|
|
|
2011-07-03 23:04:57 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void MarkEpisodeAsFetched()
|
|
|
|
|
{
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
|
|
|
.WhereAll().Have(e => e.GrabDate = null)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().MarkEpisodeAsFetched(2);
|
|
|
|
|
var episodes = db.Fetch<Episode>();
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episodes.Where(e => e.EpisodeId == 2).Single().GrabDate.Should().BeWithin(TimeSpan.FromSeconds(5)).Before(
|
|
|
|
|
DateTime.Now);
|
|
|
|
|
|
|
|
|
|
episodes.Where(e => e.GrabDate == null).Should().HaveCount(4);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-23 00:57:52 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void AddEpisode_episode_is_ignored_when_full_season_is_ignored()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
var newEpisode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = 10)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 8)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.Ignored = false)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().AddEpisode(newEpisode);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(5);
|
|
|
|
|
episodesInDb.Should().OnlyContain(e => e.Ignored);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void AddEpisode_episode_is_not_ignored_when_full_season_is_not_ignored()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
2011-07-03 23:04:57 +00:00
|
|
|
|
|
2011-07-23 00:57:52 +00:00
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.Build().ToList();
|
2011-06-22 01:12:20 +00:00
|
|
|
|
|
2011-07-23 00:57:52 +00:00
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
var newEpisode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = 10)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 8)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.Ignored = false)
|
|
|
|
|
.Build();
|
2011-06-23 06:56:17 +00:00
|
|
|
|
|
2011-07-23 00:57:52 +00:00
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().AddEpisode(newEpisode);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(5);
|
|
|
|
|
episodesInDb.Should().OnlyContain(e => e.Ignored == false);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void AddEpisode_episode_is_not_ignored_when_not_full_season_is_not_ignored()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.WhereTheFirst(2)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.AndTheRemaining()
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
var newEpisode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.SeriesId = 10)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.EpisodeNumber = 8)
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
.With(e => e.Ignored = false)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().AddEpisode(newEpisode);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(5);
|
|
|
|
|
episodesInDb.Where(e => e.EpisodeNumber == 8 && !e.Ignored).Should().HaveCount(1);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
2011-08-04 01:45:45 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IgnoreEpisode_Ignore()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().SetEpisodeIgnore(1, true);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(4);
|
|
|
|
|
episodesInDb.Where(e => e.Ignored).Should().HaveCount(1);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IgnoreEpisode_RemoveIgnore()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().SetEpisodeIgnore(1, false);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(4);
|
|
|
|
|
episodesInDb.Where(e => !e.Ignored).Should().HaveCount(1);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IgnoreSeason_Ignore()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(4);
|
|
|
|
|
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IgnoreSeason_RemoveIgnore()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, false);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(4);
|
|
|
|
|
episodesInDb.Where(e => !e.Ignored).Should().HaveCount(4);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
2011-08-04 05:44:24 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IgnoreSeason_Ignore_Half()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.WhereTheFirst(2)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
|
|
|
|
.AndTheRemaining()
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
episodes.ForEach(c => db.Insert(c));
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
|
|
|
|
|
|
|
|
|
episodesInDb.Should().HaveCount(4);
|
|
|
|
|
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void EpisodesWithoutFiles_no_specials()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 10)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
2011-08-04 05:56:42 +00:00
|
|
|
|
.Have(c => c.Ignored = true)
|
2011-08-04 05:44:24 +00:00
|
|
|
|
.WhereTheFirst(2)
|
|
|
|
|
.Have(c => c.EpisodeFileId = 0)
|
2011-08-04 05:56:42 +00:00
|
|
|
|
.WhereSection(1, 2)
|
|
|
|
|
.Have(c => c.Ignored = false)
|
2011-08-04 05:44:24 +00:00
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
var specials = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 0)
|
|
|
|
|
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
|
|
|
|
.Have(c => c.EpisodeFileId = 0)
|
2011-08-04 05:56:42 +00:00
|
|
|
|
.WhereTheFirst(1)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.AndTheRemaining()
|
|
|
|
|
.Have(c => c.Ignored = false)
|
2011-08-04 05:44:24 +00:00
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
db.Insert(series);
|
|
|
|
|
db.InsertMany(episodes);
|
|
|
|
|
db.InsertMany(specials);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-08-29 03:03:40 +00:00
|
|
|
|
var missingFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(false);
|
2011-08-04 05:44:24 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-08-04 05:56:42 +00:00
|
|
|
|
missingFiles.Should().HaveCount(1);
|
|
|
|
|
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(1);
|
2011-08-04 05:44:24 +00:00
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void EpisodesWithoutFiles_with_specials()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 10)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(4)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
2011-08-04 05:56:42 +00:00
|
|
|
|
.Have(c => c.Ignored = true)
|
2011-08-04 05:44:24 +00:00
|
|
|
|
.WhereTheFirst(2)
|
|
|
|
|
.Have(c => c.EpisodeFileId = 0)
|
2011-08-29 03:03:40 +00:00
|
|
|
|
.WhereSection(1, 2)
|
2011-08-04 05:56:42 +00:00
|
|
|
|
.Have(c => c.Ignored = false)
|
2011-08-04 05:44:24 +00:00
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
var specials = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 0)
|
|
|
|
|
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
|
|
|
|
.Have(c => c.EpisodeFileId = 0)
|
2011-08-04 05:56:42 +00:00
|
|
|
|
.WhereTheFirst(1)
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.AndTheRemaining()
|
|
|
|
|
.Have(c => c.Ignored = false)
|
2011-08-04 05:44:24 +00:00
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
db.Insert(series);
|
|
|
|
|
db.InsertMany(episodes);
|
|
|
|
|
db.InsertMany(specials);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var missingFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(true);
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-08-04 05:56:42 +00:00
|
|
|
|
missingFiles.Should().HaveCount(2);
|
|
|
|
|
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(2);
|
2011-08-04 05:44:24 +00:00
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
2011-09-04 03:05:44 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void EpisodesWithFiles_success()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 10)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
|
|
|
|
.With(c => c.EpisodeFileId = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Have(c => c.EpisodeFile = episodeFile)
|
|
|
|
|
.Have(c => c.EpisodeFileId = episodeFile.EpisodeFileId)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
db.Insert(series);
|
|
|
|
|
db.Insert(episodeFile);
|
|
|
|
|
db.InsertMany(episodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var withFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithFiles();
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
withFiles.Should().HaveCount(2);
|
|
|
|
|
withFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(0);
|
|
|
|
|
withFiles.Where(e => e.EpisodeFile == null).Should().HaveCount(0);
|
|
|
|
|
|
|
|
|
|
foreach (var withFile in withFiles)
|
|
|
|
|
{
|
|
|
|
|
withFile.EpisodeFile.Should().NotBeNull();
|
2011-09-04 07:45:58 +00:00
|
|
|
|
withFile.Series.Title.Should().NotBeNullOrEmpty();
|
2011-09-04 03:05:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void EpisodesWithFiles_no_files()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 10)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
|
|
|
|
.Have(c => c.Ignored = true)
|
|
|
|
|
.Have(c => c.EpisodeFileId = 0)
|
|
|
|
|
.Build().ToList();
|
|
|
|
|
|
|
|
|
|
db.Insert(series);
|
|
|
|
|
db.InsertMany(episodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var withFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithFiles();
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
withFiles.Should().HaveCount(0);
|
|
|
|
|
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
2011-09-05 02:56:45 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisodesByFileId_multi_episodes()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 10)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.EpisodeFileId = 12345)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
db.Insert(series);
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var episodes = mocker.Resolve<EpisodeProvider>().GetEpisodesByFileId(12345);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episodes.Should().HaveCount(2);
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetEpisodesByFileId_single_episode()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 10)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(c => c.SeriesId = 10)
|
|
|
|
|
.With(c => c.SeasonNumber = 1)
|
|
|
|
|
.With(c => c.EpisodeFileId = 12345)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
db.Insert(series);
|
|
|
|
|
db.Insert(fakeEpisode);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var episodes = mocker.Resolve<EpisodeProvider>().GetEpisodesByFileId(12345);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
episodes.Should().HaveCount(1);
|
|
|
|
|
episodes.First().ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisode);
|
|
|
|
|
mocker.VerifyAllMocks();
|
|
|
|
|
}
|
2011-09-14 04:37:22 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsFirstOrLastEpisodeInSeason_false()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsFirstOrLastEpisodeOfSeason(10, 1, 5);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsFirstOrLastEpisodeInSeason_true_first()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsFirstOrLastEpisodeOfSeason(10, 1, 1);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void IsFirstOrLastEpisodeInSeason_true_last()
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 10)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EpisodeProvider>().IsFirstOrLastEpisodeOfSeason(10, 1, 10);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
2011-10-12 03:44:19 +00:00
|
|
|
|
|
2011-10-14 15:37:19 +00:00
|
|
|
|
[TestCase("The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.Unpacking, 1)]
|
|
|
|
|
[TestCase("The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.Failed, 1)]
|
|
|
|
|
[TestCase("The Office (US) - S01E01E02 - Episode Title", PostDownloadStatusType.Unpacking, 2)]
|
|
|
|
|
[TestCase("The Office (US) - S01E01E02 - Episode Title", PostDownloadStatusType.Failed, 2)]
|
2011-10-12 03:44:19 +00:00
|
|
|
|
[TestCase("The Office (US) - Season 01 - Episode Title", PostDownloadStatusType.Unpacking, 10)]
|
|
|
|
|
[TestCase("The Office (US) - Season 01 - Episode Title", PostDownloadStatusType.Failed, 10)]
|
|
|
|
|
public void SetPostDownloadStatus(string folderName, PostDownloadStatusType postDownloadStatus, int episodeCount)
|
|
|
|
|
{
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.SeriesId = 12345)
|
|
|
|
|
.With(s => s.CleanTitle = "officeus")
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-10-14 15:37:19 +00:00
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(episodeCount)
|
2011-10-12 03:44:19 +00:00
|
|
|
|
.WhereAll()
|
|
|
|
|
.Have(c => c.SeriesId = 12345)
|
|
|
|
|
.Have(c => c.SeasonNumber = 1)
|
|
|
|
|
.Have(c => c.PostDownloadStatus = PostDownloadStatusType.Unknown)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
db.Insert(fakeSeries);
|
|
|
|
|
db.InsertMany(fakeEpisodes);
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-10-14 15:37:19 +00:00
|
|
|
|
mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId), postDownloadStatus);
|
2011-10-12 03:44:19 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
|
result.Where(e => e.PostDownloadStatus == postDownloadStatus).Count().Should().Be(episodeCount);
|
|
|
|
|
}
|
2011-05-20 04:18:51 +00:00
|
|
|
|
}
|
2011-05-29 03:37:19 +00:00
|
|
|
|
}
|