moved Series,Seasons,Episodes to their own folders.
This commit is contained in:
@@ -7,6 +7,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -6,6 +6,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Sabnzbd;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
-227
@@ -1,227 +0,0 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_DeleteInvalidEpisodes : SqlCeTest
|
||||
{
|
||||
[Test]
|
||||
public void Delete_None_Valid_TvDbEpisodeId()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.TvDbEpisodeId = tvDbSeries.First().Id)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_None_TvDbEpisodeId_is_zero()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.TvDbEpisodeId = 0)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_None_TvDbEpisodeId_is_null()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.TvDbEpisodeId = null)
|
||||
.Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_TvDbId()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.SeasonNumber = 20)
|
||||
.With(e => e.EpisodeNumber = 20)
|
||||
.With(e => e.TvDbEpisodeId = 300)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(0);
|
||||
}
|
||||
|
||||
//Other series, by season/episode + by tvdbid
|
||||
[Test]
|
||||
public void Delete_TvDbId_multiple_series()
|
||||
{
|
||||
//Setup
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = seriesId)
|
||||
.Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.SeasonNumber = 20)
|
||||
.With(e => e.EpisodeNumber = 20)
|
||||
.With(e => e.TvDbEpisodeId = 300)
|
||||
.Build();
|
||||
|
||||
//Other Series
|
||||
var otherFakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = 12345)
|
||||
.Build();
|
||||
|
||||
var otherFakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = 12345)
|
||||
.With(e => e.SeasonNumber = 20)
|
||||
.With(e => e.EpisodeNumber = 20)
|
||||
.With(e => e.TvDbEpisodeId = 300)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
Db.Insert(otherFakeSeries);
|
||||
Db.Insert(otherFakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_do_anything_if_episode_list_is_empty()
|
||||
{
|
||||
WithStrictMocker();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, new List<TvdbEpisode>());
|
||||
}
|
||||
}
|
||||
}
|
||||
-276
@@ -1,276 +0,0 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : SqlCeTest
|
||||
{
|
||||
private EpisodeProvider episodeProvider;
|
||||
|
||||
private Series fakeSeries;
|
||||
private Series fakeDailySeries;
|
||||
|
||||
private Episode fakeEpisode;
|
||||
private Episode fakeDailyEpisode;
|
||||
private Episode fakeEpisode2;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
|
||||
fakeDailySeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.IsDaily = true)
|
||||
.Build();
|
||||
|
||||
fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.Title = "Episode (1)")
|
||||
.Build();
|
||||
|
||||
fakeEpisode2 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.SeasonNumber = fakeEpisode.SeasonNumber)
|
||||
.With(e => e.EpisodeNumber = fakeEpisode.EpisodeNumber + 1)
|
||||
.With(e => e.Title = "Episode (2)")
|
||||
.Build();
|
||||
|
||||
fakeDailyEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.AirDate = DateTime.Now.Date)
|
||||
.With(e => e.Title = "Daily Episode 1")
|
||||
.Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
episodeProvider = Mocker.Resolve<EpisodeProvider>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void existing_single_episode_should_return_single_existing_episode()
|
||||
{
|
||||
Db.Insert(fakeEpisode);
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
SeasonNumber = fakeEpisode.SeasonNumber,
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(1);
|
||||
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title);
|
||||
VerifyEpisode(ep[0], fakeEpisode);
|
||||
Db.Fetch<Episode>().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void single_none_existing_episode_should_return_nothing_and_add_nothing()
|
||||
{
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
SeasonNumber = fakeEpisode.SeasonNumber,
|
||||
EpisodeNumbers = new List<int> { 10 }
|
||||
};
|
||||
|
||||
var episode = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
episode.Should().BeEmpty();
|
||||
Db.Fetch<Episode>().Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void single_none_existing_series_should_return_nothing_and_add_nothing()
|
||||
{
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
SeasonNumber = 10,
|
||||
EpisodeNumbers = new List<int> { 10 }
|
||||
};
|
||||
|
||||
var episode = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
episode.Should().BeEmpty();
|
||||
Db.Fetch<Episode>().Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void existing_multi_episode_should_return_all_episodes()
|
||||
{
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
Db.Insert(fakeEpisode2);
|
||||
|
||||
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
SeasonNumber = fakeEpisode.SeasonNumber,
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber, fakeEpisode2.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(2);
|
||||
Db.Fetch<Episode>().Should().HaveCount(2);
|
||||
|
||||
VerifyEpisode(ep[0], fakeEpisode);
|
||||
VerifyEpisode(ep[1], fakeEpisode2);
|
||||
parseResult.EpisodeTitle.Should().Be("Episode");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void none_existing_multi_episode_should_not_return_or_add_anything()
|
||||
{
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
SeasonNumber = fakeEpisode.SeasonNumber,
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber, fakeEpisode2.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().BeEmpty();
|
||||
Db.Fetch<Episode>().Should().BeEmpty();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_null()
|
||||
{
|
||||
//Act
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult());
|
||||
//Assert
|
||||
episodes.Should().NotBeNull();
|
||||
episodes.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_empty()
|
||||
{
|
||||
//Act
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult { EpisodeNumbers = new List<int>() });
|
||||
//Assert
|
||||
episodes.Should().NotBeNull();
|
||||
episodes.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_single_episode_when_air_date_is_provided()
|
||||
{
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeDailyEpisode);
|
||||
|
||||
//Act
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
|
||||
|
||||
//Assert
|
||||
episodes.Should().HaveCount(1);
|
||||
VerifyEpisode(episodes[0], fakeDailyEpisode);
|
||||
|
||||
Db.Fetch<Episode>().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_add_episode_when_episode_doesnt_exist()
|
||||
{
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
|
||||
|
||||
//Assert
|
||||
episodes.Should().HaveCount(0);
|
||||
Db.Fetch<Episode>().Should().HaveCount(0);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetEpisodeParseResult_should_return_single_title_for_multiple_episodes()
|
||||
{
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
Db.Insert(fakeEpisode2);
|
||||
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
SeasonNumber = fakeEpisode.SeasonNumber,
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber, fakeEpisode2.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(2);
|
||||
Db.Fetch<Episode>().Should().HaveCount(2);
|
||||
|
||||
VerifyEpisode(ep[0], fakeEpisode);
|
||||
VerifyEpisode(ep[1], fakeEpisode2);
|
||||
|
||||
parseResult.EpisodeTitle.Should().Be("Episode");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEpisodeParseResult_should_return_single_title_for_single_episode()
|
||||
{
|
||||
Db.Insert(fakeEpisode);
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
SeasonNumber = fakeEpisode.SeasonNumber,
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(1);
|
||||
Db.Fetch<Episode>().Should().HaveCount(1);
|
||||
ep.First().ShouldHave().AllPropertiesBut(e => e.Series);
|
||||
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEpisodeParseResult_should_return_nothing_when_series_is_not_daily_but_parsed_daily()
|
||||
{
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
var parseResult = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
AirDate = DateTime.Today
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().BeEmpty();
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
private void VerifyEpisode(Episode actual, Episode excpected)
|
||||
{
|
||||
actual.ShouldHave().AllProperties().But(e => e.Series).But(e => e.EpisodeFile).EqualTo(excpected);
|
||||
}
|
||||
}
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class GetEpisodeBySceneNumberFixture : SqlCeTest
|
||||
{
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
_series = Builder<Series>
|
||||
.CreateNew()
|
||||
.Build();
|
||||
|
||||
Db.Insert(_series);
|
||||
}
|
||||
|
||||
public void WithNullSceneNumbering()
|
||||
{
|
||||
_episode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.SeriesId = _series.SeriesId)
|
||||
.Build();
|
||||
|
||||
Db.Insert(_episode);
|
||||
Db.Execute("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL");
|
||||
}
|
||||
|
||||
public void WithSceneNumbering()
|
||||
{
|
||||
_episode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.SeriesId = _series.SeriesId)
|
||||
.Build();
|
||||
|
||||
Db.Insert(_episode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_no_episodes_in_db()
|
||||
{
|
||||
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_no_matching_episode_is_found()
|
||||
{
|
||||
WithNullSceneNumbering();
|
||||
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_episode_if_matching_episode_is_found()
|
||||
{
|
||||
WithSceneNumbering();
|
||||
|
||||
var result = Mocker.Resolve<EpisodeProvider>()
|
||||
.GetEpisodeBySceneNumbering(_series.SeriesId, _episode.SceneSeasonNumber, _episode.SceneEpisodeNumber);
|
||||
|
||||
result.EpisodeId.Should().Be(_episode.EpisodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
|
||||
@@ -7,6 +7,7 @@ using FluentAssertions;
|
||||
using NLog;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -7,6 +7,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
@@ -4,6 +4,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
@@ -8,6 +8,7 @@ using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
@@ -6,6 +6,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
@@ -7,6 +7,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Search;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
@@ -6,6 +6,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
@@ -24,7 +25,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
||||
{
|
||||
}
|
||||
|
||||
public override List<EpisodeParseResult> PerformSearch(Repository.Series series, dynamic options, Model.Notification.ProgressNotification notification)
|
||||
public override List<EpisodeParseResult> PerformSearch(Series series, dynamic options, Model.Notification.ProgressNotification notification)
|
||||
{
|
||||
if (options.Episode == null)
|
||||
throw new ArgumentException("Episode is invalid");
|
||||
@@ -54,12 +55,12 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
||||
return reports;
|
||||
}
|
||||
|
||||
public override SearchHistoryItem CheckReport(Repository.Series series, dynamic options, EpisodeParseResult episodeParseResult, Repository.Search.SearchHistoryItem item)
|
||||
public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, Repository.Search.SearchHistoryItem item)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void FinalizeSearch(Repository.Series series, dynamic options, bool reportsFound, Model.Notification.ProgressNotification notification)
|
||||
protected override void FinalizeSearch(Series series, dynamic options, bool reportsFound, Model.Notification.ProgressNotification notification)
|
||||
{
|
||||
logger.Warn("Unable to find {0} in any of indexers.", series.Title);
|
||||
}
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SeasonProviderTest : SqlCeTest
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
}
|
||||
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void SetIgnore_should_update_ignored_status(bool ignoreFlag)
|
||||
{
|
||||
var fakeSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.Ignored = !ignoreFlag)
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
.With(c => c.SeriesId = fakeSeason.SeriesId)
|
||||
.With(c => c.SeasonNumber = fakeSeason.SeasonId)
|
||||
.With(c => c.Ignored = !ignoreFlag)
|
||||
.Build().ToList();
|
||||
|
||||
fakeEpisodes.ForEach(c => Db.Insert(c));
|
||||
|
||||
var id = Db.Insert(fakeSeason);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonProvider>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
|
||||
|
||||
//Assert
|
||||
var season = Db.SingleOrDefault<Season>(id);
|
||||
season.Ignored.Should().Be(ignoreFlag);
|
||||
|
||||
var episodes = Db.Fetch<Episode>();
|
||||
episodes.Should().HaveSameCount(fakeEpisodes);
|
||||
episodes.Should().OnlyContain(c => c.Ignored == ignoreFlag);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
|
||||
{
|
||||
//Setup
|
||||
var fakeSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.Ignored = ignoreFlag)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeason);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||
|
||||
//Assert
|
||||
result.Should().Be(ignoreFlag);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_throw_an_exception_if_not_in_db()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => Mocker.Resolve<SeasonProvider>().IsIgnored(10, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void All_should_return_seasons_with_episodes()
|
||||
{
|
||||
const int seriesId = 10;
|
||||
|
||||
var season = Builder<Season>.CreateNew()
|
||||
.With(s => s.SeriesId = seriesId)
|
||||
.With(s => s.SeasonNumber = 4)
|
||||
.With(s => s.Ignored = true)
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.SeasonNumber = season.SeasonNumber)
|
||||
.Build();
|
||||
|
||||
Db.Insert(season);
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().All(seriesId);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(1);
|
||||
result.First().Episodes.Should().HaveCount(episodes.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void All_should_return_all_seasons_with_episodes()
|
||||
{
|
||||
const int seriesId = 10;
|
||||
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
var seasons = Builder<Season>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.SeriesId = seriesId)
|
||||
.Build();
|
||||
|
||||
var episodes = new List<Episode>();
|
||||
|
||||
for (int i = 0; i < seasons.Count; i++)
|
||||
{
|
||||
var newEps = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.SeasonNumber = i + 1)
|
||||
.Build();
|
||||
|
||||
episodes.AddRange(newEps);
|
||||
}
|
||||
|
||||
Db.InsertMany(seasons);
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().All(seriesId);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
|
||||
foreach (var season in result)
|
||||
{
|
||||
season.Episodes.Count.Should().Be(2);
|
||||
season.Episodes.Should().OnlyContain(c => c.SeasonNumber == season.SeasonNumber);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_should_add_all_seasons_for_new_series()
|
||||
{
|
||||
var seasons = new[] { 0, 1, 2, 3, 4, 5 };
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasons);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_should_add_missing_seasons()
|
||||
{
|
||||
var seasonsA = new[] { 0, 1, 2, 3 };
|
||||
var seasonsB = new[] { 0, 1, 2, 3, 4, 5 };
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasonsA);
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasonsA);
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasonsB);
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasonsB);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_marks_season_zero_as_ignored()
|
||||
{
|
||||
var seasons = new[] { 0, 1, 2, 3 };
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||
Db.Fetch<Season>().Should().Contain(c => c.SeasonNumber == 0 && c.Ignored);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_none_zero_seasons_arent_ignored()
|
||||
{
|
||||
var seasons = new[] { 1, 2, 3 };
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||
Db.Fetch<Season>().Should().OnlyContain(c => c.Ignored == false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSeason_should_return_seasons_for_specified_series_only()
|
||||
{
|
||||
var seriesA = new[] { 1, 2, 3 };
|
||||
var seriesB = new[] { 4, 5, 6 };
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(1, seriesA);
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(2, seriesB);
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(1).Should().Equal(seriesA);
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(2).Should().Equal(seriesB);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetSeason_should_return_emptylist_if_series_doesnt_exist()
|
||||
{
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(1).Should().BeEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,872 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeriesProviderTest : SqlCeTest
|
||||
{
|
||||
private IList<QualityProfile> _qualityProfiles;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_qualityProfiles = Builder<QualityProfile>
|
||||
.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(p => p.Cutoff = QualityTypes.DVD)
|
||||
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
||||
.Build();
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void Add_new_series(bool useSeasonFolder)
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.GetMock<ConfigProvider>()
|
||||
.Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder);
|
||||
|
||||
var fakeProfiles = Builder<QualityProfile>
|
||||
.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(p => p.Cutoff = QualityTypes.DVD)
|
||||
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeProfiles);
|
||||
|
||||
const string path = "C:\\Test\\";
|
||||
const string title = "Test Title";
|
||||
const int tvDbId = 1234;
|
||||
const int qualityProfileId = 2;
|
||||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
seriesProvider.AddSeries(title, path, tvDbId, qualityProfileId, null);
|
||||
|
||||
//Assert
|
||||
var series = seriesProvider.GetAllSeries();
|
||||
series.Should().HaveCount(1);
|
||||
Assert.AreEqual(path, series.First().Path);
|
||||
Assert.AreEqual(tvDbId, series.First().SeriesId);
|
||||
Assert.AreEqual(qualityProfileId, series.First().QualityProfileId);
|
||||
Assert.AreEqual(title, series.First().Title);
|
||||
series.First().SeasonFolder.Should().Be(useSeasonFolder);
|
||||
}
|
||||
|
||||
|
||||
[TestCase(0)]
|
||||
[TestCase(-1)]
|
||||
public void add_series_should_fail_if_series_is_less_than_zero(int seriesId)
|
||||
{
|
||||
WithRealDb();
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mocker.Resolve<SeriesProvider>().AddSeries("Title", "C:\\Test", seriesId, 1, null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void find_series_empty_repo()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
var series = seriesProvider.FindSeries("My Title");
|
||||
|
||||
//Assert
|
||||
Assert.IsNull(series);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
|
||||
public void Get_series_invalid_series_id_should_return_null()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
var series = seriesProvider.GetSeries(2);
|
||||
|
||||
|
||||
//Assert
|
||||
Assert.IsNull(series);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_series_by_id()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfileId = 1)
|
||||
.With(c => c.EpisodeCount = 0)
|
||||
.With(c => c.EpisodeFileCount = 0)
|
||||
.With(c => c.SeasonCount = 0)
|
||||
.Build();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>
|
||||
.CreateNew()
|
||||
.With(p => p.Cutoff = QualityTypes.DVD)
|
||||
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetSeries(1);
|
||||
|
||||
//Assert
|
||||
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
series.QualityProfile.Should().NotBeNull();
|
||||
series.QualityProfile.ShouldHave().Properties(q => q.Name, q => q.SonicAllowed, q => q.Cutoff, q => q.SonicAllowed).EqualTo(fakeQuality);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Find_series_by_cleanName_mapped()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfileId = 1)
|
||||
.With(c => c.CleanTitle = "laworder")
|
||||
.Build();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>
|
||||
.CreateNew()
|
||||
.With(p => p.Cutoff = QualityTypes.DVD)
|
||||
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
||||
.Build();
|
||||
|
||||
var id = Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
Mocker.GetMock<SceneMappingProvider>().Setup(s => s.GetSeriesId("laworder")).Returns(1);
|
||||
|
||||
var series = Mocker.Resolve<SeriesProvider>().FindSeries("laworder");
|
||||
|
||||
//Assert
|
||||
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId);
|
||||
series.QualityProfile.Should().NotBeNull();
|
||||
series.QualityProfile.ShouldHave().Properties(q => q.Name, q => q.SonicAllowed, q => q.Cutoff, q => q.AllowedString);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void find_series_empty_match()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSEries = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSEries);
|
||||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
|
||||
//Assert
|
||||
seriesProvider.FindSeries("WrongTitle").Should().BeNull();
|
||||
}
|
||||
|
||||
[TestCase("The Test", "Test")]
|
||||
[TestCase("Through the Wormhole", "Through.the.Wormhole")]
|
||||
public void find_series_match(string title, string searchTitle)
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.Title = title)
|
||||
.With(c => c.CleanTitle = Parser.NormalizeTitle(title))
|
||||
.Build();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew()
|
||||
.With(c => c.QualityProfileId = fakeSeries.QualityProfileId)
|
||||
.With(p => p.Cutoff = QualityTypes.DVD)
|
||||
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var series = Mocker.Resolve<SeriesProvider>().FindSeries(searchTitle);
|
||||
|
||||
//Assert
|
||||
series.Should().NotBeNull();
|
||||
series.SeriesId.Should().Be(series.SeriesId);
|
||||
series.Title.Should().BeEquivalentTo(series.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void is_monitored()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(Builder<Series>.CreateNew()
|
||||
.With(c => c.Monitored = true)
|
||||
.With(c => c.SeriesId = 12)
|
||||
.Build());
|
||||
|
||||
Db.Insert(Builder<Series>.CreateNew()
|
||||
.With(c => c.Monitored = false)
|
||||
.With(c => c.SeriesId = 11)
|
||||
.Build());
|
||||
|
||||
Db.InsertMany(Builder<QualityProfile>.CreateListOfSize(3)
|
||||
.All()
|
||||
.With(p => p.Cutoff = QualityTypes.DVD)
|
||||
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
||||
.Build());
|
||||
|
||||
//Act, Assert
|
||||
var provider = Mocker.Resolve<SeriesProvider>();
|
||||
provider.IsMonitored(12).Should().BeTrue();
|
||||
Assert.IsFalse(provider.IsMonitored(11));
|
||||
Assert.IsFalse(provider.IsMonitored(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_With_Count()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All().With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.Ignored = false)
|
||||
.With(e => e.AirDate = DateTime.Today)
|
||||
.TheFirst(5)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.TheLast(2)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(1))
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
Assert.AreEqual(8, series[0].EpisodeCount);
|
||||
Assert.AreEqual(3, series[0].EpisodeFileCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_With_Count_AllIgnored()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10).All().With(e => e.SeriesId = fakeSeries.SeriesId).With(e => e.Ignored = true).Random(5).With(e => e.EpisodeFileId = 0).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
Assert.AreEqual(0, series[0].EpisodeCount);
|
||||
Assert.AreEqual(0, series[0].EpisodeFileCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_With_Count_AllDownloaded()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.Ignored = false)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
Assert.AreEqual(10, series[0].EpisodeCount);
|
||||
Assert.AreEqual(10, series[0].EpisodeFileCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_With_Count_Half_Ignored()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.TheFirst(5)
|
||||
.With(e => e.Ignored = false)
|
||||
.TheLast(5)
|
||||
.With(e => e.Ignored = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
Assert.AreEqual(5, series[0].EpisodeCount);
|
||||
Assert.AreEqual(5, series[0].EpisodeFileCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_should_not_return_series_that_do_not_have_info_synced_yet()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.TheLast(2)
|
||||
.With(e => e.LastInfoSync = null)
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.First().SeriesId)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.TheFirst(5)
|
||||
.With(e => e.Ignored = false)
|
||||
.TheLast(5)
|
||||
.With(e => e.Ignored = true)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Single_Series()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.With(e => e.SeriesId = 1)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetSeries(1);
|
||||
|
||||
//Assert
|
||||
series.QualityProfile.Should().NotBeNull();
|
||||
series.QualityProfileId.Should().Be(fakeQuality.QualityProfileId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SeriesPathExists_exact_match()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var path = @"C:\Test\TV\30 Rock";
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.QualityProfileId = 1)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Path = path)
|
||||
.Build();
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
||||
//fakeSeries.ToList());
|
||||
|
||||
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(path);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SeriesPathExists_match()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var path = @"C:\Test\TV\30 Rock";
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.QualityProfileId = 1)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Path = path)
|
||||
.Build();
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
||||
//fakeSeries.ToList());
|
||||
|
||||
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(path.ToUpper());
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SeriesPathExists_match_alt()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var path = @"C:\Test\TV\The Simpsons";
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.QualityProfileId = 1)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Path = path)
|
||||
.Build();
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
||||
//fakeSeries.ToList());
|
||||
|
||||
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(@"c:\Test\Tv\the sIMpsons");
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SeriesPathExists_match_false()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var path = @"C:\Test\TV\30 Rock";
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.QualityProfileId = 1)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Path = path)
|
||||
.Build();
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
||||
//fakeSeries.ToList());
|
||||
|
||||
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(@"C:\Test\TV\Not A match");
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_Today()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.Ignored = false)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(1))
|
||||
.TheFirst(1)
|
||||
.With(e => e.AirDate = DateTime.Today)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().Be(DateTime.Today);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_Tomorrow_Last_Aired_Yesterday()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.Ignored = false)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(1))
|
||||
.TheFirst(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().Be(DateTime.Today.AddDays(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_Unknown()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.AirDate = null)
|
||||
.With(e => e.Ignored = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().NotHaveValue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_1_month()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.Ignored = false)
|
||||
.With(e => e.AirDate = DateTime.Today.AddMonths(1))
|
||||
.TheFirst(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Series_NextAiring_skip_ignored()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
||||
.With(e => e.AirDate = DateTime.Today.AddMonths(1))
|
||||
.With(e => e.Ignored = false)
|
||||
.TheFirst(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(1))
|
||||
.With(e => e.Ignored = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchForSeries_should_return_results_that_start_with_query()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("Titl");
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchForSeries_should_return_results_that_contain_the_query()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("itl");
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchForSeries_should_return_results_that_end_with_the_query()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("2");
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchForSeries_should_not_return_results_that_do_not_contain_the_query()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("NotATitle");
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SearchForSeries_should_return_results_when_query_has_special_characters()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.TheLast(1)
|
||||
.With(s => s.Title = "It's Always Sunny")
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("it's");
|
||||
|
||||
//Assert
|
||||
series.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateFromMassEdit_should_only_update_certain_values()
|
||||
{
|
||||
WithRealDb();
|
||||
var newQualityProfileId = 10;
|
||||
var newMonitored = false;
|
||||
var newSeasonFolder = false;
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.With(e => e.Monitored = true)
|
||||
.With(e => e.SeasonFolder = true)
|
||||
.With(s => s.Title = "It's Always Sunny")
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
fakeSeries[0].QualityProfileId = newQualityProfileId;
|
||||
fakeSeries[0].Monitored = newMonitored;
|
||||
fakeSeries[0].SeasonFolder = newSeasonFolder;
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeriesProvider>().UpdateFromSeriesEditor(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
result.Count.Should().Be(1);
|
||||
result.First().QualityProfileId.Should().Be(newQualityProfileId);
|
||||
result.First().Monitored.Should().Be(newMonitored);
|
||||
result.First().SeasonFolder.Should().Be(newSeasonFolder);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateFromMassEdit_should_only_update_changed_values()
|
||||
{
|
||||
WithRealDb();
|
||||
var newQualityProfileId = 10;
|
||||
var newMonitored = false;
|
||||
var newSeasonFolder = false;
|
||||
var monitored = true;
|
||||
var seasonFolder = true;
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||
.With(e => e.Monitored = monitored)
|
||||
.With(e => e.SeasonFolder = seasonFolder)
|
||||
.With(s => s.Title = "It's Always Sunny")
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
fakeSeries[0].QualityProfileId = newQualityProfileId;
|
||||
fakeSeries[0].Monitored = newMonitored;
|
||||
fakeSeries[0].SeasonFolder = newSeasonFolder;
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeriesProvider>().UpdateFromSeriesEditor(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
result.Count.Should().Be(2);
|
||||
result.First().QualityProfileId.Should().Be(newQualityProfileId);
|
||||
result.First().Monitored.Should().Be(newMonitored);
|
||||
result.First().SeasonFolder.Should().Be(newSeasonFolder);
|
||||
result.Last().QualityProfileId.Should().Be(fakeQuality.QualityProfileId);
|
||||
result.Last().Monitored.Should().Be(monitored);
|
||||
result.Last().SeasonFolder.Should().Be(seasonFolder);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void delete_series_should_delete_all_rows_related_to_the_series()
|
||||
{
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(3).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(30)
|
||||
.TheFirst(10).With(c => c.SeriesId = fakeSeries[0].SeriesId)
|
||||
.TheNext(10).With(c => c.SeriesId = fakeSeries[1].SeriesId)
|
||||
.TheNext(10).With(c => c.SeriesId = fakeSeries[2].SeriesId)
|
||||
.Build();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} | ||||