|
|
@ -2,11 +2,13 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
@ -311,5 +313,64 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|
|
|
Mocker.GetMock<MediaFileProvider>().Verify(v => v.GetFileByPath(filename), Times.Once());
|
|
|
|
Mocker.GetMock<MediaFileProvider>().Verify(v => v.GetFileByPath(filename), Times.Once());
|
|
|
|
Mocker.GetMock<DiskProvider>().Verify(v => v.MoveFile(filename.NormalizePath(), newFilePath), Times.Once());
|
|
|
|
Mocker.GetMock<DiskProvider>().Verify(v => v.MoveFile(filename.NormalizePath(), newFilePath), Times.Once());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void MoveEpisodeFile_should_use_EpisodeFiles_quality()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
|
|
|
.With(s => s.SeriesId = 5)
|
|
|
|
|
|
|
|
.With(s => s.Title = "30 Rock")
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
|
|
|
.All()
|
|
|
|
|
|
|
|
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
|
|
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const string filename = @"30 Rock - S01E01 - TBD";
|
|
|
|
|
|
|
|
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"));
|
|
|
|
|
|
|
|
var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv");
|
|
|
|
|
|
|
|
const string message = "30 Rock - 1x01 - [WEBDL]";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var file = Builder<EpisodeFile>.CreateNew()
|
|
|
|
|
|
|
|
.With(f => f.SeriesId = fakeSeries.SeriesId)
|
|
|
|
|
|
|
|
.With(f => f.Path = currentFilename)
|
|
|
|
|
|
|
|
.With(f => f.Quality = QualityTypes.WEBDL)
|
|
|
|
|
|
|
|
.With(f => f.Proper = false)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<SeriesProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.GetSeries(fakeSeries.SeriesId))
|
|
|
|
|
|
|
|
.Returns(fakeSeries);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.GetEpisodesByFileId(file.EpisodeFileId))
|
|
|
|
|
|
|
|
.Returns(fakeEpisode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<MediaFileProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries.Title, It.IsAny<QualityTypes>(), It.IsAny<bool>()))
|
|
|
|
|
|
|
|
.Returns(filename);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<MediaFileProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
|
|
|
|
|
|
|
.Returns(fi);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
|
|
|
|
|
|
|
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new Quality{ QualityType = QualityTypes.WEBDL, Proper = false })))
|
|
|
|
|
|
|
|
.Returns(message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.OnDownload("30 Rock - 1x01 - [WEBDL]", It.IsAny<Series>()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
|
|
|
var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
|
|
|
result.Should().BeTrue();
|
|
|
|
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
|
|
|
|
|
|
|
.Verify(e => e.OnDownload("30 Rock - 1x01 - [WEBDL]", It.IsAny<Series>()), Times.Once());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|