Refreshing EpisodeInfo will now set new or existing episodes that have air times prior to 1900 to null.
This commit is contained in:
parent
576f5c5c09
commit
2aaa23b11d
|
@ -326,6 +326,51 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
mocker.VerifyAllMocks();
|
mocker.VerifyAllMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RefreshEpisodeInfo_should_set_older_than_1900_to_null_for_existing_episodes()
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
const int seriesId = 71663;
|
||||||
|
|
||||||
|
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||||
|
.With(e => e.TvDbEpisodeId = 12345)
|
||||||
|
.With(e => e.AirDate = DateTime.Today)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var fakeTvDbEpisodes = Builder<TvdbSeries>.CreateNew().With(
|
||||||
|
c => c.Episodes =
|
||||||
|
new List<TvdbEpisode>(Builder<TvdbEpisode>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now)
|
||||||
|
.TheFirst(1).With(e => e.FirstAired = new DateTime(1800, 1, 1))
|
||||||
|
.Build())
|
||||||
|
).With(c => c.Id = seriesId).Build();
|
||||||
|
|
||||||
|
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
var db = TestDbHelper.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
db.Insert(fakeSeries);
|
||||||
|
db.Insert(fakeEpisode);
|
||||||
|
|
||||||
|
mocker.GetMock<TvDbProvider>()
|
||||||
|
.Setup(c => c.GetSeries(seriesId, true))
|
||||||
|
.Returns(fakeTvDbEpisodes);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
var storedEpisodes = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||||
|
storedEpisodes.Should().HaveCount(1);
|
||||||
|
storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(1);
|
||||||
|
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void RefreshEpisodeInfo_ignore_episode_zero()
|
public void RefreshEpisodeInfo_ignore_episode_zero()
|
||||||
{
|
{
|
||||||
|
|
|
@ -258,9 +258,10 @@ namespace NzbDrone.Core.Providers
|
||||||
episodeToUpdate.Overview = episode.Overview;
|
episodeToUpdate.Overview = episode.Overview;
|
||||||
|
|
||||||
if (episode.FirstAired.Year > 1900)
|
if (episode.FirstAired.Year > 1900)
|
||||||
{
|
|
||||||
episodeToUpdate.AirDate = episode.FirstAired.Date;
|
episodeToUpdate.AirDate = episode.FirstAired.Date;
|
||||||
}
|
|
||||||
|
else
|
||||||
|
episodeToUpdate.AirDate = null;
|
||||||
|
|
||||||
successCount++;
|
successCount++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue