1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 23:42:33 +01:00

fix bug where info update from tvdb would overwrite our own data, fileid, date flags ...

This commit is contained in:
kay.one 2011-04-25 15:27:03 -07:00
parent 5faeccf098
commit c8252495af
2 changed files with 50 additions and 2 deletions

View File

@ -4,6 +4,7 @@ using AutoMoq;
using FizzWare.NBuilder;
using MbUnit.Framework;
using Moq;
using Moq.Linq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -125,6 +126,47 @@ namespace NzbDrone.Core.Test
}
[Test]
[Description("Verifies that a new file imported properly")]
public void import_existing_season_file()
{
//Arrange
/////////////////////////////////////////
//Constants
const string fileName = @"WEEDS.S03E01.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi";
const int seasonNumber = 3;
const int episodeNumner = 1;
const int size = 12345;
//Fakes
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisode = Builder<Episode>.CreateNew()
.With(c => c.SeriesId = fakeSeries.SeriesId)
.With(c => c.EpisodeFileId = 12).Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
//mocker.GetMock<EpisodeProvider>()
// .Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode)
// .Verifiable();
mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
//Act
var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
//Assert
mocker.VerifyAllMocks();
Assert.IsNull(result);
}
[Test]
[Description("Verifies that a new file imported properly")]
public void import_sample_file()

View File

@ -183,14 +183,20 @@ namespace NzbDrone.Core.Providers
SeasonId = episode.SeasonId,
SeasonNumber = episode.SeasonNumber,
SeriesId = seriesId,
Title = episode.EpisodeName
Title = episode.EpisodeName,
LastInfoSync = DateTime.Now
};
var existingEpisode = GetEpisode(episode.SeriesId, episode.SeasonNumber, episode.EpisodeNumber);
if (existingEpisode != null)
{
//TODO: Write test for this, possibly make it future proof, we should only copy fields that come from tvdb
newEpisode.EpisodeId = existingEpisode.EpisodeId;
newEpisode.EpisodeFileId = existingEpisode.EpisodeFileId;
newEpisode.LastDiskSync = existingEpisode.LastDiskSync;
newEpisode.Status = existingEpisode.Status;
updateList.Add(newEpisode);
}
else