mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-26 01:27:00 +00:00
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
2 changed files with 48 additions and 2 deletions
|
@ -326,6 +326,51 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
|
|||
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]
|
||||
public void RefreshEpisodeInfo_ignore_episode_zero()
|
||||
{
|
||||
|
|
|
@ -258,9 +258,10 @@ public virtual void RefreshEpisodeInfo(Series series)
|
|||
episodeToUpdate.Overview = episode.Overview;
|
||||
|
||||
if (episode.FirstAired.Year > 1900)
|
||||
{
|
||||
episodeToUpdate.AirDate = episode.FirstAired.Date;
|
||||
}
|
||||
|
||||
else
|
||||
episodeToUpdate.AirDate = null;
|
||||
|
||||
successCount++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue