|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test
|
|
|
|
public class EpisodeProviderTest_DeleteInvalidEpisodes : TestBase
|
|
|
|
public class EpisodeProviderTest_DeleteInvalidEpisodes : TestBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Delete_None()
|
|
|
|
public void Delete_None_Valid_TvDbEpisodeId()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
//Setup
|
|
|
|
const int seriesId = 71663;
|
|
|
|
const int seriesId = 71663;
|
|
|
@ -42,8 +42,7 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
|
|
|
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeasonNumber = 20)
|
|
|
|
.With(e => e.TvDbEpisodeId = tvDbSeries.Episodes.First().Id)
|
|
|
|
.With(e => e.EpisodeNumber = 20)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
@ -63,7 +62,7 @@ namespace NzbDrone.Core.Test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Delete_TvDbId()
|
|
|
|
public void Delete_None_TvDbEpisodeId_is_zero()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
//Setup
|
|
|
|
const int seriesId = 71663;
|
|
|
|
const int seriesId = 71663;
|
|
|
@ -83,9 +82,7 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
|
|
|
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeasonNumber = 20)
|
|
|
|
.With(e => e.TvDbEpisodeId = 0)
|
|
|
|
.With(e => e.EpisodeNumber = 20)
|
|
|
|
|
|
|
|
.With(e => e.TvDbEpisodeId = 300)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
@ -101,11 +98,11 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
result.Should().HaveCount(0);
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Delete_EpisodeNumber()
|
|
|
|
public void Delete_None_TvDbEpisodeId_is_null()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
//Setup
|
|
|
|
const int seriesId = 71663;
|
|
|
|
const int seriesId = 71663;
|
|
|
@ -125,9 +122,7 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
|
|
|
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
.With(e => e.TvDbEpisodeId = null)
|
|
|
|
.With(e => e.EpisodeNumber = 20)
|
|
|
|
|
|
|
|
.With(e => e.TvDbEpisodeId = 1)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
@ -143,11 +138,11 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
result.Should().HaveCount(0);
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void Delete_Both()
|
|
|
|
public void Delete_TvDbId()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Setup
|
|
|
|
//Setup
|
|
|
|
const int seriesId = 71663;
|
|
|
|
const int seriesId = 71663;
|
|
|
@ -165,46 +160,27 @@ namespace NzbDrone.Core.Test
|
|
|
|
.With(c => c.SeriesId = seriesId)
|
|
|
|
.With(c => c.SeriesId = seriesId)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
var fakeEpisode1 = Builder<Episode>.CreateNew()
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
.With(e => e.SeasonNumber = 20)
|
|
|
|
.With(e => e.EpisodeNumber = 20)
|
|
|
|
.With(e => e.EpisodeNumber = 20)
|
|
|
|
.With(e => e.TvDbEpisodeId = 1)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fakeEpisode2 = Builder<Episode>.CreateNew()
|
|
|
|
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
|
|
|
.With(e => e.TvDbEpisodeId = 300)
|
|
|
|
.With(e => e.TvDbEpisodeId = 300)
|
|
|
|
.Build();
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
//This should not be deleted
|
|
|
|
|
|
|
|
var fakeEpisode3 = Builder<Episode>.CreateNew()
|
|
|
|
|
|
|
|
.With(e => e.SeriesId = seriesId)
|
|
|
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
|
|
|
.With(e => e.TvDbEpisodeId = 1)
|
|
|
|
|
|
|
|
.With(e => e.Title = "Not Deleted")
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
|
|
db.Insert(fakeSeries);
|
|
|
|
db.Insert(fakeSeries);
|
|
|
|
db.Insert(fakeEpisode1);
|
|
|
|
db.Insert(fakeEpisode);
|
|
|
|
db.Insert(fakeEpisode2);
|
|
|
|
|
|
|
|
db.Insert(fakeEpisode3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
//Act
|
|
|
|
mocker.Resolve<EpisodeProvider>().DeleteInvalidEpisodes(fakeSeries, tvDbSeries);
|
|
|
|
mocker.Resolve<EpisodeProvider>().DeleteInvalidEpisodes(fakeSeries, tvDbSeries);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.Should().HaveCount(0);
|
|
|
|
result.First().Title.Should().Be("Not Deleted");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Other series, by season/episode + by tvdbid
|
|
|
|
//Other series, by season/episode + by tvdbid
|
|
|
@ -263,61 +239,5 @@ namespace NzbDrone.Core.Test
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void Delete_EpisodeNumber_multiple_series()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//Setup
|
|
|
|
|
|
|
|
const int seriesId = 71663;
|
|
|
|
|
|
|
|
const int episodeCount = 10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tvDbSeries = Builder<TvdbSeries>.CreateNew().With(
|
|
|
|
|
|
|
|
c => c.Episodes =
|
|
|
|
|
|
|
|
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(episodeCount).
|
|
|
|
|
|
|
|
WhereAll()
|
|
|
|
|
|
|
|
.Have(l => l.Language = new TvdbLanguage(0, "eng", "a"))
|
|
|
|
|
|
|
|
.Build())
|
|
|
|
|
|
|
|
).With(c => c.Id = seriesId).Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = 1)
|
|
|
|
|
|
|
|
.With(e => e.EpisodeNumber = 20)
|
|
|
|
|
|
|
|
.With(e => e.TvDbEpisodeId = 1)
|
|
|
|
|
|
|
|
.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 = 1)
|
|
|
|
|
|
|
|
.With(e => e.EpisodeNumber = 4)
|
|
|
|
|
|
|
|
.With(e => e.TvDbEpisodeId = 2)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var db = MockLib.GetEmptyDatabase();
|
|
|
|
|
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.Insert(fakeSeries);
|
|
|
|
|
|
|
|
db.Insert(fakeEpisode);
|
|
|
|
|
|
|
|
db.Insert(otherFakeSeries);
|
|
|
|
|
|
|
|
db.Insert(otherFakeEpisode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
|
|
|
mocker.Resolve<EpisodeProvider>().DeleteInvalidEpisodes(fakeSeries, tvDbSeries);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
|
|
|
var result = db.Fetch<Episode>();
|
|
|
|
|
|
|
|
result.Should().HaveCount(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|