1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 01:27:00 +00:00

Update episode info now uses UpdateMany, InsertMany

This commit is contained in:
kay.one 2011-08-28 20:03:40 -07:00
parent 2980c91f19
commit 9244a4e6ef
2 changed files with 12 additions and 22 deletions

View file

@ -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);

View file

@ -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);