2013-03-01 10:03:41 +03:00
|
|
|
using System.Linq;
|
2010-10-24 10:46:58 +03:00
|
|
|
using FizzWare.NBuilder;
|
2011-06-03 00:06:46 +03:00
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
2013-02-24 09:48:52 +03:00
|
|
|
using NzbDrone.Core.Configuration;
|
2013-03-01 10:03:41 +03:00
|
|
|
using NzbDrone.Core.MediaFiles;
|
2013-02-19 09:01:03 +03:00
|
|
|
using NzbDrone.Core.Tv;
|
2011-05-19 06:55:35 +03:00
|
|
|
using NzbDrone.Core.Test.Framework;
|
2010-10-21 04:49:23 +03:00
|
|
|
|
2013-03-01 10:03:41 +03:00
|
|
|
namespace NzbDrone.Core.Test.MediaFileTests
|
2010-10-21 04:49:23 +03:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2013-03-05 04:47:51 +03:00
|
|
|
public class MediaFileServiceTest : CoreTest<MediaFileService>
|
2010-10-21 04:49:23 +03:00
|
|
|
{
|
2011-06-18 07:08:17 +03:00
|
|
|
|
2011-06-21 02:46:54 +03:00
|
|
|
[Test]
|
2013-01-01 06:45:57 +03:00
|
|
|
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]", "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
|
2011-06-21 02:46:54 +03:00
|
|
|
public void CleanFileName(string name, string expectedName)
|
|
|
|
{
|
2013-03-05 04:47:51 +03:00
|
|
|
MediaFileService.CleanFilename(name).Should().Be(expectedName);
|
2011-06-21 02:46:54 +03:00
|
|
|
}
|
2011-06-21 04:49:16 +03:00
|
|
|
|
2011-06-22 06:40:24 +03:00
|
|
|
[Test]
|
|
|
|
[TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season %0s", @"C:\Test\30 Rock\Season 01\30 Rock - S01E05 - Episode Title.mkv")]
|
|
|
|
[TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season %s", @"C:\Test\30 Rock\Season 1\30 Rock - S01E05 - Episode Title.mkv")]
|
|
|
|
[TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season %0s", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")]
|
|
|
|
[TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season %s", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")]
|
|
|
|
[TestCase("30 Rock - S01E05 - Episode Title", 1, true, "ReallyUglySeasonFolder %s", @"C:\Test\30 Rock\ReallyUglySeasonFolder 1\30 Rock - S01E05 - Episode Title.mkv")]
|
|
|
|
public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int seasonNumber, bool useSeasonFolder, string seasonFolderFormat, string expectedPath)
|
|
|
|
{
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
.With(s => s.Title = "30 Rock")
|
|
|
|
.With(s => s.Path = @"C:\Test\30 Rock")
|
|
|
|
.With(s => s.SeasonFolder = useSeasonFolder)
|
|
|
|
.Build();
|
|
|
|
|
2013-02-24 22:39:31 +03:00
|
|
|
Mocker.GetMock<IConfigService>().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat);
|
2011-06-22 06:40:24 +03:00
|
|
|
|
2013-03-05 04:47:51 +03:00
|
|
|
Subject.CalculateFilePath(fakeSeries, 1, filename, ".mkv").FullName.Should().Be(expectedPath);
|
2012-04-18 00:44:20 +03:00
|
|
|
}
|
2010-10-21 04:49:23 +03:00
|
|
|
}
|
2011-04-10 05:44:01 +03:00
|
|
|
}
|