2013-01-13 08:24:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2013-03-02 18:25:39 +00:00
|
|
|
|
using NzbDrone.Core.ReferenceData;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-01-13 08:24:48 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Search;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
|
|
|
|
{
|
|
|
|
|
public class GetSearchTitleFixture : TestBase
|
|
|
|
|
{
|
|
|
|
|
private Series _series;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
_series = Builder<Series>
|
|
|
|
|
.CreateNew()
|
|
|
|
|
.With(s => s.Title = "Hawaii Five-0")
|
|
|
|
|
.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithSceneMapping()
|
|
|
|
|
{
|
2013-03-02 18:25:39 +00:00
|
|
|
|
Mocker.GetMock<SceneMappingService>()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.Setup(s => s.GetSceneName(_series.Id, -1))
|
2013-01-13 08:24:48 +00:00
|
|
|
|
.Returns("Hawaii Five 0 2010");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_series_title_when_there_is_no_scene_mapping()
|
|
|
|
|
{
|
|
|
|
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
|
|
|
|
.Should().Be(_series.Title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_scene_mapping_when_one_exists()
|
|
|
|
|
{
|
|
|
|
|
WithSceneMapping();
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
|
|
|
|
.Should().Be("Hawaii Five 0 2010");
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-24 06:36:37 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_season_scene_name_when_one_exists()
|
|
|
|
|
{
|
2013-03-02 18:25:39 +00:00
|
|
|
|
Mocker.GetMock<SceneMappingService>()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.Setup(s => s.GetSceneName(_series.Id, 5))
|
2013-01-24 06:36:37 +00:00
|
|
|
|
.Returns("Hawaii Five 0 2010 - Season 5");
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
|
|
|
|
.Should().Be("Hawaii Five 0 2010 - Season 5");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_series_scene_name_when_one_for_season_does_not_exist()
|
|
|
|
|
{
|
|
|
|
|
WithSceneMapping();
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
|
|
|
|
.Should().Be("Hawaii Five 0 2010");
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-13 08:24:48 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void should_replace_ampersand_with_and()
|
|
|
|
|
{
|
|
|
|
|
_series.Title = "Franklin & Bash";
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
|
|
|
|
.Should().Be("Franklin and Bash");
|
|
|
|
|
}
|
2013-01-23 03:57:51 +00:00
|
|
|
|
|
|
|
|
|
[TestCase("Betty White's Off Their Rockers", "Betty Whites Off Their Rockers")]
|
|
|
|
|
[TestCase("Star Wars: The Clone Wars", "Star Wars The Clone Wars")]
|
|
|
|
|
[TestCase("Hawaii Five-0", "Hawaii Five-0")]
|
|
|
|
|
public void should_replace_some_special_characters(string input, string expected)
|
|
|
|
|
{
|
|
|
|
|
_series.Title = input;
|
|
|
|
|
|
2013-03-02 18:25:39 +00:00
|
|
|
|
Mocker.GetMock<SceneMappingService>()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.Setup(s => s.GetSceneName(_series.Id, -1))
|
2013-01-23 03:57:51 +00:00
|
|
|
|
.Returns("");
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
|
|
|
|
.Should().Be(expected);
|
|
|
|
|
}
|
2013-01-13 08:24:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|