2013-04-15 03:41:39 +02:00
|
|
|
|
/*
|
|
|
|
|
using System;
|
2012-02-22 05:43:19 +01:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-24 20:18:48 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
2012-02-22 05:43:19 +01:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2013-04-15 03:41:39 +02:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-02-19 07:01:03 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-22 05:43:19 +01:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-02-17 06:44:06 +01:00
|
|
|
|
public class EpisodeParseResultTest : CoreTest
|
2012-02-22 05:43:19 +01:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_single_season_episode()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.EpisodeNumbers = new List<int> { 3 };
|
|
|
|
|
parseResult.FullSeason = false;
|
|
|
|
|
parseResult.AirDate = null;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_single_season_episode_proper()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.EpisodeNumbers = new List<int> { 3 };
|
|
|
|
|
parseResult.FullSeason = false;
|
|
|
|
|
parseResult.AirDate = null;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p [proper]");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_multi_season_episode()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
|
|
|
|
|
parseResult.FullSeason = false;
|
|
|
|
|
parseResult.AirDate = null;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_multi_season_episode_proper()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
|
|
|
|
|
parseResult.FullSeason = false;
|
|
|
|
|
parseResult.AirDate = null;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p [proper]");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_full_season()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.FullSeason = true;
|
|
|
|
|
parseResult.AirDate = null;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_full_season_proper()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.FullSeason = true;
|
|
|
|
|
parseResult.AirDate = null;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p [proper]");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_daily_show()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.FullSeason = true;
|
|
|
|
|
parseResult.AirDate = new DateTime(2010, 12, 30);
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void tostring_daily_show_proper()
|
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parseResult = new RemoteEpisode();
|
2012-02-22 05:43:19 +01:00
|
|
|
|
parseResult.SeriesTitle = "My Series";
|
|
|
|
|
parseResult.SeasonNumber = 12;
|
|
|
|
|
parseResult.FullSeason = true;
|
|
|
|
|
parseResult.AirDate = new DateTime(2010, 12, 30);
|
2013-02-27 04:19:22 +01:00
|
|
|
|
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
2012-02-22 05:43:19 +01:00
|
|
|
|
|
|
|
|
|
|
2013-01-01 04:45:57 +01:00
|
|
|
|
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p [proper]");
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 20:18:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly object[] SabNamingCases =
|
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
|
|
|
|
|
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
|
|
|
|
|
new object[] { 1, new[] { 2 }, "", Quality.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
|
|
|
|
|
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p]" },
|
|
|
|
|
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p] [Proper]" },
|
|
|
|
|
new object[] { 1, new[] { 2, 4 }, "", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - [HDTV-720p] [Proper]" },
|
2013-02-24 20:18:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test, TestCaseSource("SabNamingCases")]
|
2013-02-27 04:19:22 +01:00
|
|
|
|
public void create_proper_sab_titles(int seasons, int[] episodes, string title, Quality quality, bool proper, string expected)
|
2013-02-24 20:18:48 +01:00
|
|
|
|
{
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Title = "My Series Name")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = new List<Episode>();
|
|
|
|
|
|
|
|
|
|
foreach (var episode in episodes)
|
|
|
|
|
fakeEpisodes.Add(Builder<Episode>
|
|
|
|
|
.CreateNew()
|
|
|
|
|
.With(e => e.EpisodeNumber = episode)
|
|
|
|
|
.With(e => e.Title = title)
|
|
|
|
|
.Build());
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parsResult = new RemoteEpisode()
|
2013-02-24 20:18:48 +01:00
|
|
|
|
{
|
|
|
|
|
AirDate = DateTime.Now,
|
|
|
|
|
EpisodeNumbers = episodes.ToList(),
|
|
|
|
|
Quality = new QualityModel(quality, proper),
|
|
|
|
|
SeasonNumber = seasons,
|
|
|
|
|
Series = series,
|
|
|
|
|
EpisodeTitle = title,
|
|
|
|
|
Episodes = fakeEpisodes
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parsResult.GetDownloadTitle().Should().Be(expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase(true, Result = "My Series Name - Season 1 [Bluray720p] [Proper]")]
|
|
|
|
|
[TestCase(false, Result = "My Series Name - Season 1 [Bluray720p]")]
|
|
|
|
|
public string create_proper_sab_season_title(bool proper)
|
|
|
|
|
{
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Title = "My Series Name")
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parsResult = new RemoteEpisode()
|
2013-02-24 20:18:48 +01:00
|
|
|
|
{
|
|
|
|
|
AirDate = DateTime.Now,
|
2013-02-27 04:19:22 +01:00
|
|
|
|
Quality = new QualityModel(Quality.Bluray720p, proper),
|
2013-02-24 20:18:48 +01:00
|
|
|
|
SeasonNumber = 1,
|
|
|
|
|
Series = series,
|
|
|
|
|
EpisodeTitle = "My Episode Title",
|
|
|
|
|
FullSeason = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return parsResult.GetDownloadTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase(true, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p] [Proper]")]
|
|
|
|
|
[TestCase(false, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p]")]
|
|
|
|
|
public string create_proper_sab_daily_titles(bool proper)
|
|
|
|
|
{
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
2013-03-24 05:16:00 +01:00
|
|
|
|
.With(c => c.SeriesType = SeriesTypes.Daily)
|
2013-02-24 20:18:48 +01:00
|
|
|
|
.With(c => c.Title = "My Series Name")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var episode = Builder<Episode>.CreateNew()
|
|
|
|
|
.With(e => e.Title = "My Episode Title")
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parsResult = new RemoteEpisode
|
2013-02-24 20:18:48 +01:00
|
|
|
|
{
|
|
|
|
|
AirDate = new DateTime(2011, 12, 1),
|
2013-02-27 04:19:22 +01:00
|
|
|
|
Quality = new QualityModel(Quality.Bluray720p, proper),
|
2013-02-24 20:18:48 +01:00
|
|
|
|
Series = series,
|
|
|
|
|
EpisodeTitle = "My Episode Title",
|
|
|
|
|
Episodes = new List<Episode> { episode }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return parsResult.GetDownloadTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_not_repeat_the_same_episode_title()
|
|
|
|
|
{
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(c => c.Title = "My Series Name")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.SeasonNumber = 5)
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
.With(e => e.Title = "My Episode Title (1)")
|
|
|
|
|
.TheLast(1)
|
|
|
|
|
.With(e => e.Title = "My Episode Title (2)")
|
|
|
|
|
.Build();
|
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
|
var parsResult = new RemoteEpisode
|
2013-02-24 20:18:48 +01:00
|
|
|
|
{
|
|
|
|
|
AirDate = DateTime.Now,
|
|
|
|
|
EpisodeNumbers = new List<int> { 10, 11 },
|
2013-02-27 04:19:22 +01:00
|
|
|
|
Quality = new QualityModel(Quality.HDTV720p, false),
|
2013-02-24 20:18:48 +01:00
|
|
|
|
SeasonNumber = 35,
|
|
|
|
|
Series = series,
|
|
|
|
|
Episodes = fakeEpisodes
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parsResult.GetDownloadTitle().Should().Be("My Series Name - 5x01-5x02 - My Episode Title [HDTV-720p]");
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 05:43:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-15 03:41:39 +02:00
|
|
|
|
*/
|