2011-06-18 08:29:38 +00:00
|
|
|
|
using System;
|
2012-10-14 00:54:46 +00:00
|
|
|
|
using System.Collections.Generic;
|
2011-05-22 16:53:21 +00:00
|
|
|
|
using System.Linq;
|
2011-11-14 00:22:18 +00:00
|
|
|
|
|
2011-05-22 16:53:21 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
2011-06-02 21:06:46 +00:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2011-05-22 16:53:21 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-06-15 02:31:41 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-05-22 16:53:21 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-06-18 04:39:02 +00:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2011-05-19 03:55:35 +00:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-10-20 23:42:17 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests
|
2011-05-22 16:53:21 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-02-02 20:54:03 +00:00
|
|
|
|
public class SeriesProviderTest : SqlCeTest
|
2011-05-22 16:53:21 +00:00
|
|
|
|
{
|
2012-10-14 00:54:46 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-15 02:31:41 +00:00
|
|
|
|
[TestCase(true)]
|
|
|
|
|
[TestCase(false)]
|
|
|
|
|
public void Add_new_series(bool useSeasonFolder)
|
2011-05-22 16:53:21 +00:00
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-16 06:33:01 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.GetMock<ConfigProvider>()
|
2011-06-15 02:31:41 +00:00
|
|
|
|
.Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder);
|
2011-06-16 06:33:01 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
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();
|
2011-06-14 05:52:12 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeProfiles);
|
2011-10-18 21:46:06 +00:00
|
|
|
|
|
2011-05-22 16:53:21 +00:00
|
|
|
|
const string path = "C:\\Test\\";
|
2012-02-29 08:25:41 +00:00
|
|
|
|
const string title = "Test Title";
|
2011-05-22 16:53:21 +00:00
|
|
|
|
const int tvDbId = 1234;
|
|
|
|
|
const int qualityProfileId = 2;
|
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
2012-09-19 06:06:09 +00:00
|
|
|
|
seriesProvider.AddSeries(title, path, tvDbId, qualityProfileId, null);
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
var series = seriesProvider.GetAllSeries();
|
2011-06-02 21:06:46 +00:00
|
|
|
|
series.Should().HaveCount(1);
|
2011-05-22 16:53:21 +00:00
|
|
|
|
Assert.AreEqual(path, series.First().Path);
|
|
|
|
|
Assert.AreEqual(tvDbId, series.First().SeriesId);
|
|
|
|
|
Assert.AreEqual(qualityProfileId, series.First().QualityProfileId);
|
2012-02-29 08:25:41 +00:00
|
|
|
|
Assert.AreEqual(title, series.First().Title);
|
2011-06-15 02:31:41 +00:00
|
|
|
|
series.First().SeasonFolder.Should().Be(useSeasonFolder);
|
2011-05-22 16:53:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 22:16:14 +00:00
|
|
|
|
|
|
|
|
|
[TestCase(0)]
|
|
|
|
|
[TestCase(-1)]
|
|
|
|
|
public void add_series_should_fail_if_series_is_less_than_zero(int seriesId)
|
|
|
|
|
{
|
|
|
|
|
WithRealDb();
|
2012-09-19 06:06:09 +00:00
|
|
|
|
Assert.Throws<ArgumentOutOfRangeException>(() => Mocker.Resolve<SeriesProvider>().AddSeries("Title", "C:\\Test", seriesId, 1, null));
|
2012-01-13 22:16:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-22 16:53:21 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void find_series_empty_repo()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
2011-05-22 16:53:21 +00:00
|
|
|
|
var series = seriesProvider.FindSeries("My Title");
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsNull(series);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-18 03:36:22 +00:00
|
|
|
|
[Test]
|
2011-06-19 05:56:52 +00:00
|
|
|
|
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
|
2011-06-18 03:36:22 +00:00
|
|
|
|
public void Get_series_invalid_series_id_should_return_null()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-18 03:36:22 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
2011-06-18 03:36:22 +00:00
|
|
|
|
var series = seriesProvider.GetSeries(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsNull(series);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-18 04:39:02 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void Get_series_by_id()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-18 04:39:02 +00:00
|
|
|
|
|
2011-06-18 08:29:38 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.QualityProfileId = 1)
|
2011-06-20 07:40:45 +00:00
|
|
|
|
.With(c => c.EpisodeCount = 0)
|
|
|
|
|
.With(c => c.EpisodeFileCount = 0)
|
|
|
|
|
.With(c => c.SeasonCount = 0)
|
2011-06-18 08:29:38 +00:00
|
|
|
|
.Build();
|
2012-10-14 00:54:46 +00:00
|
|
|
|
|
|
|
|
|
var fakeQuality = Builder<QualityProfile>
|
|
|
|
|
.CreateNew()
|
|
|
|
|
.With(p => p.Cutoff = QualityTypes.DVD)
|
|
|
|
|
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
|
|
|
|
.Build();
|
2011-06-18 04:39:02 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-06-18 04:39:02 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetSeries(1);
|
2011-06-18 04:39:02 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-09-28 17:56:30 +00:00
|
|
|
|
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId, s => s.NextAiring).EqualTo(fakeSeries);
|
2011-06-18 04:39:02 +00:00
|
|
|
|
series.QualityProfile.Should().NotBeNull();
|
2011-06-18 08:29:38 +00:00
|
|
|
|
series.QualityProfile.ShouldHave().Properties(q => q.Name, q => q.SonicAllowed, q => q.Cutoff, q => q.SonicAllowed).EqualTo(fakeQuality);
|
2011-06-20 06:28:42 +00:00
|
|
|
|
|
2011-06-18 04:39:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-18 07:17:47 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void Find_series_by_cleanName_mapped()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-18 07:17:47 +00:00
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.QualityProfileId = 1)
|
|
|
|
|
.With(c => c.CleanTitle = "laworder")
|
|
|
|
|
.Build();
|
2012-10-14 00:54:46 +00:00
|
|
|
|
|
|
|
|
|
var fakeQuality = Builder<QualityProfile>
|
|
|
|
|
.CreateNew()
|
|
|
|
|
.With(p => p.Cutoff = QualityTypes.DVD)
|
|
|
|
|
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
|
|
|
|
.Build();
|
2011-06-18 07:17:47 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var id = Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-06-18 07:17:47 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
Mocker.GetMock<SceneMappingProvider>().Setup(s => s.GetSeriesId("laworder")).Returns(1);
|
2011-06-18 07:17:47 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().FindSeries("laworder");
|
2011-06-18 07:17:47 +00:00
|
|
|
|
|
|
|
|
|
//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);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-22 16:53:21 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void find_series_empty_match()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
|
|
|
|
|
2011-12-15 04:29:21 +00:00
|
|
|
|
var fakeSEries = Builder<Series>.CreateNew()
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Db.Insert(fakeSEries);
|
|
|
|
|
|
2011-05-22 16:53:21 +00:00
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-12-15 04:29:21 +00:00
|
|
|
|
seriesProvider.FindSeries("WrongTitle").Should().BeNull();
|
2011-05-22 16:53:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-15 02:31:41 +00:00
|
|
|
|
[TestCase("The Test", "Test")]
|
|
|
|
|
[TestCase("Through the Wormhole", "Through.the.Wormhole")]
|
2011-05-22 16:53:21 +00:00
|
|
|
|
public void find_series_match(string title, string searchTitle)
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
|
|
|
|
|
2011-12-15 04:29:21 +00:00
|
|
|
|
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)
|
2012-10-14 00:54:46 +00:00
|
|
|
|
.With(p => p.Cutoff = QualityTypes.DVD)
|
|
|
|
|
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
|
2011-12-15 04:29:21 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-06-18 07:17:47 +00:00
|
|
|
|
|
2011-05-22 16:53:21 +00:00
|
|
|
|
//Act
|
2011-12-15 04:29:21 +00:00
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().FindSeries(searchTitle);
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
2011-12-15 04:29:21 +00:00
|
|
|
|
series.Should().NotBeNull();
|
|
|
|
|
series.SeriesId.Should().Be(series.SeriesId);
|
|
|
|
|
series.Title.Should().BeEquivalentTo(series.Title);
|
2011-05-22 16:53:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void is_monitored()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(Builder<Series>.CreateNew()
|
2011-05-22 16:53:21 +00:00
|
|
|
|
.With(c => c.Monitored = true)
|
|
|
|
|
.With(c => c.SeriesId = 12)
|
|
|
|
|
.Build());
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(Builder<Series>.CreateNew()
|
2011-06-17 02:48:24 +00:00
|
|
|
|
.With(c => c.Monitored = false)
|
|
|
|
|
.With(c => c.SeriesId = 11)
|
|
|
|
|
.Build());
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
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());
|
2011-05-22 16:53:21 +00:00
|
|
|
|
|
|
|
|
|
//Act, Assert
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var provider = Mocker.Resolve<SeriesProvider>();
|
2011-06-23 06:56:17 +00:00
|
|
|
|
provider.IsMonitored(12).Should().BeTrue();
|
2011-05-22 16:53:21 +00:00
|
|
|
|
Assert.IsFalse(provider.IsMonitored(11));
|
|
|
|
|
Assert.IsFalse(provider.IsMonitored(1));
|
|
|
|
|
}
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_With_Count()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
2011-07-10 02:45:31 +00:00
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.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)
|
2011-10-23 05:39:14 +00:00
|
|
|
|
.TheLast(2)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(1))
|
2011-07-10 02:45:31 +00:00
|
|
|
|
.Build();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
2011-07-10 02:45:31 +00:00
|
|
|
|
Assert.AreEqual(8, series[0].EpisodeCount);
|
|
|
|
|
Assert.AreEqual(3, series[0].EpisodeFileCount);
|
2011-06-20 07:13:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_With_Count_AllIgnored()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
2011-10-23 05:39:14 +00:00
|
|
|
|
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();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//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()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
2011-07-10 02:58:36 +00:00
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
|
|
|
|
.With(e => e.Ignored = false)
|
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
2011-07-10 02:58:36 +00:00
|
|
|
|
.Build();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//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()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
|
|
|
|
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
|
|
|
|
.TheFirst(5)
|
|
|
|
|
.With(e => e.Ignored = false)
|
2011-10-23 05:39:14 +00:00
|
|
|
|
.TheLast(5)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.With(e => e.Ignored = true)
|
2011-06-20 07:13:17 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
Assert.AreEqual(5, series[0].EpisodeCount);
|
|
|
|
|
Assert.AreEqual(5, series[0].EpisodeFileCount);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-23 04:14:01 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_should_not_return_series_that_do_not_have_info_synced_yet()
|
|
|
|
|
{
|
|
|
|
|
WithRealDb();
|
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2012-01-23 04:14:01 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 07:13:17 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Single_Series()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-06-20 07:13:17 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
|
|
|
|
.With(e => e.SeriesId = 1)
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetSeries(1);
|
2011-06-20 07:13:17 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.QualityProfile.Should().NotBeNull();
|
|
|
|
|
series.QualityProfileId.Should().Be(fakeQuality.QualityProfileId);
|
|
|
|
|
}
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SeriesPathExists_exact_match()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
var path = @"C:\Test\TV\30 Rock";
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.QualityProfileId = 1)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(c => c.Path = path)
|
2011-07-29 01:03:24 +00:00
|
|
|
|
.Build();
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
2011-10-18 21:46:06 +00:00
|
|
|
|
//fakeSeries.ToList());
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(path);
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SeriesPathExists_match()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
var path = @"C:\Test\TV\30 Rock";
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.QualityProfileId = 1)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(c => c.Path = path)
|
2011-07-29 01:03:24 +00:00
|
|
|
|
.Build();
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
2011-07-29 01:03:24 +00:00
|
|
|
|
//fakeSeries.ToList());
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(path.ToUpper());
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SeriesPathExists_match_alt()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
var path = @"C:\Test\TV\The Simpsons";
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.QualityProfileId = 1)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(c => c.Path = path)
|
2011-07-29 01:03:24 +00:00
|
|
|
|
.Build();
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
2011-07-29 01:03:24 +00:00
|
|
|
|
//fakeSeries.ToList());
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(@"c:\Test\Tv\the sIMpsons");
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SeriesPathExists_match_false()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
var path = @"C:\Test\TV\30 Rock";
|
|
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(c => c.QualityProfileId = 1)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(c => c.Path = path)
|
2011-07-29 01:03:24 +00:00
|
|
|
|
.Build();
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
//Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
|
2011-07-29 01:03:24 +00:00
|
|
|
|
//fakeSeries.ToList());
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var result = Mocker.Resolve<SeriesProvider>().SeriesPathExists(@"C:\Test\TV\Not A match");
|
2011-07-29 01:03:24 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
result.Should().BeFalse();
|
|
|
|
|
}
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_NextAiring_Today()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.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)
|
2011-09-28 17:56:30 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
series[0].NextAiring.Should().Be(DateTime.Today);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_NextAiring_Tomorrow_Last_Aired_Yesterday()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.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))
|
2011-09-28 17:56:30 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
series[0].NextAiring.Should().Be(DateTime.Today.AddDays(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_NextAiring_Unknown()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
|
|
|
|
.With(e => e.AirDate = null)
|
|
|
|
|
.With(e => e.Ignored = false)
|
2011-09-28 17:56:30 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
series[0].NextAiring.Should().NotHaveValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_NextAiring_1_month()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.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))
|
2011-09-28 17:56:30 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-09-28 17:56:30 +00:00
|
|
|
|
|
2011-10-03 23:38:22 +00:00
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Get_Series_NextAiring_skip_ignored()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-10-03 23:38:22 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-10-03 23:38:22 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
2011-10-18 21:46:06 +00:00
|
|
|
|
.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)
|
2011-10-03 23:38:22 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.Insert(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
|
|
|
|
Db.InsertMany(fakeEpisodes);
|
2011-10-03 23:38:22 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Mocker.Resolve<QualityProvider>();
|
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
2011-10-03 23:38:22 +00:00
|
|
|
|
|
2011-09-28 17:56:30 +00:00
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
|
|
|
|
|
}
|
2011-10-20 23:36:47 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SearchForSeries_should_return_results_that_start_with_query()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-10-20 23:36:47 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-10-20 23:36:47 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-23 05:39:14 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
2011-10-20 23:36:47 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-10-20 23:36:47 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("Titl");
|
2011-10-20 23:36:47 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-10-21 06:06:36 +00:00
|
|
|
|
public void SearchForSeries_should_return_results_that_contain_the_query()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-10-21 06:06:36 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-10-21 06:06:36 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-23 05:39:14 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
2011-10-21 06:06:36 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-10-21 06:06:36 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("itl");
|
2011-10-21 06:06:36 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SearchForSeries_should_return_results_that_end_with_the_query()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-10-21 06:06:36 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-10-21 06:06:36 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-23 05:39:14 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
2011-10-21 06:06:36 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-10-21 06:06:36 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("2");
|
2011-10-21 06:06:36 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SearchForSeries_should_not_return_results_that_do_not_contain_the_query()
|
2011-10-20 23:36:47 +00:00
|
|
|
|
{
|
2011-12-15 04:29:21 +00:00
|
|
|
|
WithRealDb();
|
2011-10-20 23:36:47 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-10-20 23:36:47 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
2011-10-23 05:39:14 +00:00
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
2011-10-20 23:36:47 +00:00
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-10-20 23:36:47 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("NotATitle");
|
2011-10-20 23:36:47 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(0);
|
|
|
|
|
}
|
2011-12-08 08:44:22 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SearchForSeries_should_return_results_when_query_has_special_characters()
|
|
|
|
|
{
|
2011-12-09 00:55:00 +00:00
|
|
|
|
WithRealDb();
|
2011-12-08 08:44:22 +00:00
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2011-12-08 08:44:22 +00:00
|
|
|
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
|
|
|
|
.TheLast(1)
|
|
|
|
|
.With(s => s.Title = "It's Always Sunny")
|
|
|
|
|
.Build();
|
|
|
|
|
|
2011-12-09 00:55:00 +00:00
|
|
|
|
Db.InsertMany(fakeSeries);
|
|
|
|
|
Db.Insert(fakeQuality);
|
2011-12-08 08:44:22 +00:00
|
|
|
|
|
|
|
|
|
//Act
|
2011-12-09 00:55:00 +00:00
|
|
|
|
var series = Mocker.Resolve<SeriesProvider>().SearchForSeries("it's");
|
2011-12-08 08:44:22 +00:00
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
series.Should().HaveCount(1);
|
|
|
|
|
}
|
2012-01-20 07:50:45 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void UpdateFromMassEdit_should_only_update_certain_values()
|
|
|
|
|
{
|
|
|
|
|
WithRealDb();
|
|
|
|
|
var newQualityProfileId = 10;
|
|
|
|
|
var newMonitored = false;
|
|
|
|
|
var newSeasonFolder = false;
|
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2012-01-20 07:50:45 +00:00
|
|
|
|
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
|
2012-02-23 22:31:50 +00:00
|
|
|
|
Mocker.Resolve<SeriesProvider>().UpdateFromSeriesEditor(fakeSeries);
|
2012-01-20 07:50:45 +00:00
|
|
|
|
|
|
|
|
|
//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;
|
|
|
|
|
|
2012-10-14 00:54:46 +00:00
|
|
|
|
var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
|
2012-01-20 07:50:45 +00:00
|
|
|
|
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
|
2012-02-23 22:31:50 +00:00
|
|
|
|
Mocker.Resolve<SeriesProvider>().UpdateFromSeriesEditor(fakeSeries);
|
2012-01-20 07:50:45 +00:00
|
|
|
|
|
|
|
|
|
//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);
|
|
|
|
|
}
|
2012-02-28 05:50:56 +00:00
|
|
|
|
|
|
|
|
|
[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)
|
2012-02-29 08:25:41 +00:00
|
|
|
|
.TheFirst(10).With(c => c.SeriesId = fakeSeries[0].SeriesId)
|
|
|
|
|
.TheNext(10).With(c => c.SeriesId = fakeSeries[1].SeriesId)
|
2012-02-28 05:50:56 +00:00
|
|
|
|
.TheNext(10).With(c => c.SeriesId = fakeSeries[2].SeriesId)
|
|
|
|
|
.Build();
|
2012-02-29 08:25:41 +00:00
|
|
|
|
|
2012-02-28 05:50:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2011-05-22 16:53:21 +00:00
|
|
|
|
}
|
2011-04-22 22:24:05 +00:00
|
|
|
|
} |