You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.7 KiB
91 lines
2.7 KiB
12 years ago
|
using FizzWare.NBuilder;
|
||
|
using FluentAssertions;
|
||
|
using NUnit.Framework;
|
||
12 years ago
|
using NzbDrone.Core.ReferenceData;
|
||
12 years ago
|
using NzbDrone.Core.Tv;
|
||
12 years ago
|
using NzbDrone.Test.Common;
|
||
|
|
||
12 years ago
|
namespace NzbDrone.Core.Test.IndexerSearchTests
|
||
12 years ago
|
{
|
||
|
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()
|
||
|
{
|
||
12 years ago
|
Mocker.GetMock<SceneMappingService>()
|
||
12 years ago
|
.Setup(s => s.GetSceneName(_series.Id, -1))
|
||
12 years ago
|
.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");
|
||
|
}
|
||
|
|
||
12 years ago
|
[Test]
|
||
|
public void should_return_season_scene_name_when_one_exists()
|
||
|
{
|
||
12 years ago
|
Mocker.GetMock<SceneMappingService>()
|
||
12 years ago
|
.Setup(s => s.GetSceneName(_series.Id, 5))
|
||
12 years ago
|
.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");
|
||
|
}
|
||
|
|
||
12 years ago
|
[Test]
|
||
|
public void should_replace_ampersand_with_and()
|
||
|
{
|
||
|
_series.Title = "Franklin & Bash";
|
||
|
|
||
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
||
|
.Should().Be("Franklin and Bash");
|
||
|
}
|
||
12 years ago
|
|
||
|
[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;
|
||
|
|
||
12 years ago
|
Mocker.GetMock<SceneMappingService>()
|
||
12 years ago
|
.Setup(s => s.GetSceneName(_series.Id, -1))
|
||
12 years ago
|
.Returns("");
|
||
|
|
||
|
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
|
||
|
.Should().Be(expected);
|
||
|
}
|
||
12 years ago
|
}
|
||
|
}
|