mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-10 23:29:53 +02:00
Update episode info now uses UpdateMany, InsertMany
This commit is contained in:
parent
2980c91f19
commit
9244a4e6ef
@ -388,8 +388,8 @@ public void existing_episodes_only_calls_Update()
|
||||
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
mocker.GetMock<IDatabase>().Verify(c => c.Insert(It.IsAny<Object>()), Times.Never());
|
||||
mocker.GetMock<IDatabase>().Verify(c => c.Update(It.IsAny<Object>()), Times.Exactly(tvdbSeries.Episodes.Count));
|
||||
mocker.GetMock<IDatabase>().Verify(c => c.InsertMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 0)), Times.Once());
|
||||
mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 5)), Times.Once());
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
@ -499,9 +499,8 @@ public void existing_episodes_keep_their_episodeId_file_id()
|
||||
.Returns(currentEpisodes);
|
||||
|
||||
mocker.GetMock<IDatabase>()
|
||||
.Setup(c => c.Update(It.IsAny<Episode>()))
|
||||
.Returns(1)
|
||||
.Callback<Episode>(ep => updatedEpisodes.Add(ep));
|
||||
.Setup(c => c.UpdateMany(It.IsAny<IEnumerable<Episode>>()))
|
||||
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes =ep.ToList());
|
||||
|
||||
//Act
|
||||
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
@ -241,17 +241,8 @@ public virtual void RefreshEpisodeInfo(Series series)
|
||||
}
|
||||
}
|
||||
|
||||
using (var tran = _database.GetTransaction())
|
||||
{
|
||||
newList.ForEach(AddEpisode);
|
||||
updateList.ForEach(episode => _database.Update(episode));
|
||||
|
||||
//Shouldn't run if Database is a mock since transaction will be null
|
||||
if (_database.GetType().Namespace != "Castle.Proxies" && tran != null)
|
||||
{
|
||||
tran.Complete();
|
||||
}
|
||||
}
|
||||
_database.InsertMany(newList);
|
||||
_database.UpdateMany(updateList);
|
||||
|
||||
Logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ",
|
||||
tvDbSeriesInfo.SeriesName, successCount, failCount);
|
||||
|
Loading…
Reference in New Issue
Block a user