mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Fixed: fixed an issue where season ignore check wasn't working correctly.
Fixed: unavailable nzbdrone service will no longer block series from being added.
This commit is contained in:
parent
ada0a3bfbc
commit
c5df00cc87
@ -157,7 +157,7 @@ public void AutoIgnoreSeason_new_series_should_not_ignore_any()
|
||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -184,7 +184,7 @@ public void AutoIgnoreSeason_existing_should_not_ignore_currentseason()
|
||||
|
||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -210,9 +210,9 @@ public void AutoIgnoreSeason_existing_should_ignore_seasons_with_no_file()
|
||||
|
||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 0, true), Times.Once());
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 1, true), Times.Never());
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.SetSeasonIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 0, true), Times.Once());
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 1, true), Times.Never());
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1020,122 +1020,6 @@ public void IgnoreEpisode_RemoveIgnore()
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IgnoreSeason_Ignore()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 1)
|
||||
.With(c => c.Ignored = false)
|
||||
.Build().ToList();
|
||||
|
||||
episodes.ForEach(c => Db.Insert(c));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
|
||||
episodesInDb.Should().HaveCount(4);
|
||||
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IgnoreSeason_RemoveIgnore()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 1)
|
||||
.With(c => c.Ignored = true)
|
||||
.Build().ToList();
|
||||
|
||||
episodes.ForEach(c => Db.Insert(c));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, false);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
|
||||
episodesInDb.Should().HaveCount(4);
|
||||
episodesInDb.Where(e => !e.Ignored).Should().HaveCount(4);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IgnoreSeason_Ignore_Half()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 1)
|
||||
.With(c => c.Ignored = true)
|
||||
.TheFirst(2)
|
||||
.With(c => c.Ignored = false)
|
||||
.Build().ToList();
|
||||
|
||||
episodes.ForEach(c => Db.Insert(c));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
|
||||
episodesInDb.Should().HaveCount(4);
|
||||
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IgnoreSeason_should_call_SetIgnore_in_season_provider_one_time_only()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 1)
|
||||
.With(c => c.Ignored = false)
|
||||
.Build().ToList();
|
||||
|
||||
var season = new Season
|
||||
{
|
||||
SeriesId = 10,
|
||||
SeasonNumber = 1,
|
||||
Ignored = false
|
||||
};
|
||||
|
||||
Db.Insert(season);
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>().Setup(s => s.SetIgnore(10, 1, true)).Verifiable();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
|
||||
episodesInDb.Should().HaveCount(4);
|
||||
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>().Verify(s => s.SetIgnore(10, 1, true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EpisodesWithoutFiles_no_specials()
|
||||
{
|
||||
|
@ -25,13 +25,11 @@ public void Delete_None_Valid_TvDbEpisodeId()
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
var tvDbSeries = Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
.Build();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = seriesId)
|
||||
@ -39,7 +37,7 @@ public void Delete_None_Valid_TvDbEpisodeId()
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.TvDbEpisodeId = tvDbSeries.Episodes.First().Id)
|
||||
.With(e => e.TvDbEpisodeId = tvDbSeries.First().Id)
|
||||
.Build();
|
||||
|
||||
|
||||
@ -65,13 +63,10 @@ public void Delete_None_TvDbEpisodeId_is_zero()
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
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)
|
||||
@ -105,13 +100,10 @@ public void Delete_None_TvDbEpisodeId_is_null()
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
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)
|
||||
@ -145,13 +137,10 @@ public void Delete_TvDbId()
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
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)
|
||||
@ -188,13 +177,10 @@ public void Delete_TvDbId_multiple_series()
|
||||
const int seriesId = 71663;
|
||||
const int episodeCount = 10;
|
||||
|
||||
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
||||
c => c.Episodes =
|
||||
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
||||
All()
|
||||
.With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
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)
|
||||
@ -236,5 +222,15 @@ public void Delete_TvDbId_multiple_series()
|
||||
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>());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using System.Net;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
@ -191,5 +192,20 @@ public void UpdateDailySeries_should_update_series_should_not_overwrite_existing
|
||||
result.Where(s => s.IsDaily).Should().HaveCount(3);
|
||||
result.Where(s => !s.IsDaily).Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void broken_service_should_not_cause_this_call_to_fail()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<string>()))
|
||||
.Throws(new WebException())
|
||||
.Verifiable();
|
||||
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -25,89 +24,51 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SeasonProviderTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void AddSeason_should_insert_season_to_database_with_ignored_false()
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var seriesId = 10;
|
||||
var seasonNumber = 50;
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonProvider>().Add(seriesId, seasonNumber);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Season>();
|
||||
result.Should().HaveCount(1);
|
||||
result.First().SeriesId.Should().Be(seriesId);
|
||||
result.First().SeasonNumber.Should().Be(seasonNumber);
|
||||
result.First().Ignored.Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void AddSeason_should_insert_season_to_database_with_preset_ignored_status(bool isIgnored)
|
||||
public void SetIgnore_should_update_ignored_status(bool ignoreFlag)
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var seriesId = 10;
|
||||
var seasonNumber = 50;
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonProvider>().Add(seriesId, seasonNumber, isIgnored);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Season>();
|
||||
result.Should().HaveCount(1);
|
||||
result.First().SeriesId.Should().Be(seriesId);
|
||||
result.First().SeasonNumber.Should().Be(seasonNumber);
|
||||
result.First().Ignored.Should().Be(isIgnored);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeleteSeason_should_remove_season_from_database()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeason = Builder<Season>.CreateNew().Build();
|
||||
|
||||
Db.Insert(fakeSeason);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonProvider>().Delete(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Season>();
|
||||
result.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetIgnore_should_update_ignored_status()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.Ignored = false)
|
||||
.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, true);
|
||||
Mocker.Resolve<SeasonProvider>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
|
||||
|
||||
//Assert
|
||||
var result = Db.SingleOrDefault<Season>(id);
|
||||
result.Ignored.Should().BeTrue();
|
||||
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);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_return_ignored_status_of_season()
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Setup
|
||||
var fakeSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.Ignored = false)
|
||||
.With(s => s.Ignored = ignoreFlag)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeason);
|
||||
@ -116,94 +77,13 @@ public void IsIgnored_should_return_ignored_status_of_season()
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||
|
||||
//Assert
|
||||
result.Should().Be(fakeSeason.Ignored);
|
||||
Db.Fetch<Season>().Count.Should().Be(1);
|
||||
result.Should().Be(ignoreFlag);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_return_true_if_not_in_db_and_is_season_zero()
|
||||
public void IsIgnored_should_throw_an_exception_if_not_in_db()
|
||||
{
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 0);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
Db.Fetch<Season>().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_return_false_if_not_in_db_and_is_season_one()
|
||||
{
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
Db.Fetch<Season>().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_return_false_if_not_in_db_and_previous_season_is_not_ignored()
|
||||
{
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
var lastSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.SeriesId = 10)
|
||||
.With(s => s.SeasonNumber = 4)
|
||||
.With(s => s.Ignored = false)
|
||||
.Build();
|
||||
|
||||
Db.Insert(lastSeason);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 5);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
Db.Fetch<Season>().Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_return_true_if_not_in_db_and_previous_season_is_ignored()
|
||||
{
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
var lastSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.SeriesId = 10)
|
||||
.With(s => s.SeasonNumber = 4)
|
||||
.With(s => s.Ignored = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(lastSeason);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 5);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
Db.Fetch<Season>().Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_return_false_if_not_in_db_and_previous_season_does_not_exist()
|
||||
{
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(10, 5);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
Db.Fetch<Season>().Should().HaveCount(1);
|
||||
Assert.Throws<InvalidOperationException>(() => Mocker.Resolve<SeasonProvider>().IsIgnored(10, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -211,9 +91,6 @@ public void All_should_return_seasons_with_episodes()
|
||||
{
|
||||
const int seriesId = 10;
|
||||
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
var season = Builder<Season>.CreateNew()
|
||||
.With(s => s.SeriesId = seriesId)
|
||||
.With(s => s.SeasonNumber = 4)
|
||||
@ -272,10 +149,73 @@ public void All_should_return_all_seasons_with_episodes()
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
|
||||
foreach(var season in result)
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -817,5 +817,19 @@ public void UpdateFromMassEdit_should_only_update_changed_values()
|
||||
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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} |