1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-30 20:05:41 +00:00
Radarr/NzbDrone.Core.Test/TvDbProviderTest.cs

132 lines
4.4 KiB
C#
Raw Normal View History

2011-05-22 16:53:21 +00:00
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
2011-06-02 21:06:46 +00:00
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
2010-09-23 03:19:47 +00:00
namespace NzbDrone.Core.Test
{
2011-06-02 21:06:46 +00:00
[NUnit.Framework.TestFixture]
2010-10-07 22:17:24 +00:00
// ReSharper disable InconsistentNaming
public class TvDbProviderTest : TestBase
2010-09-23 03:19:47 +00:00
{
[Test]
2011-06-02 21:06:46 +00:00
[TestCase("The Simpsons")]
[TestCase("Family Guy")]
[TestCase("South Park")]
2010-10-05 06:21:18 +00:00
public void successful_search(string title)
2010-09-23 03:19:47 +00:00
{
var result = new TvDbProvider().SearchSeries(title);
2011-06-02 21:06:46 +00:00
result.Should().NotBeEmpty();
result[0].SeriesName.Should().Be(title);
2010-09-23 03:19:47 +00:00
}
2010-10-05 06:21:18 +00:00
[Test]
2011-06-02 21:06:46 +00:00
[TestCase("The Simpsons")]
[TestCase("Family Guy")]
[TestCase("South Park")]
2010-10-05 06:21:18 +00:00
public void successful_title_lookup(string title)
{
var tvCont = new TvDbProvider();
var result = tvCont.GetSeries(title);
2011-06-02 21:06:46 +00:00
result.SeriesName.Should().Be(title);
2010-10-05 06:21:18 +00:00
}
[Test]
2011-06-02 21:06:46 +00:00
[TestCase(new object[] { "CAPITAL", "capital", true })]
[TestCase(new object[] { "Something!!", "Something", true })]
[TestCase(new object[] { "Simpsons 2000", "Simpsons", true })]
[TestCase(new object[] { "Simp222sons", "Simpsons", true })]
[TestCase(new object[] { "Simpsons", "The Simpsons", true })]
[TestCase(new object[] { "Law and order", "Law & order", true })]
[TestCase(new object[] { "xxAndxx", "xxxx", false })]
[TestCase(new object[] { "Andxx", "xx", false })]
[TestCase(new object[] { "xxAnd", "xx", false })]
[TestCase(new object[] { "Thexx", "xx", false })]
[TestCase(new object[] { "Thexx", "xx", false })]
[TestCase(new object[] { "xxThexx", "xxxxx", false })]
[TestCase(new object[] { "Simpsons The", "Simpsons", true })]
2010-10-05 06:21:18 +00:00
public void Name_match_test(string a, string b, bool match)
{
bool result = TvDbProvider.IsTitleMatch(a, b);
Assert.AreEqual(match, result, "{0} , {1}", a, b);
}
[Test]
public void no_search_result()
{
//setup
var tvdbProvider = new TvDbProvider();
//act
2011-03-30 06:18:35 +00:00
var result = tvdbProvider.SearchSeries(Guid.NewGuid().ToString());
2010-10-05 06:21:18 +00:00
//assert
2011-06-02 21:06:46 +00:00
result.Should().BeEmpty();
2010-10-05 06:21:18 +00:00
}
[Test]
public void no_result_title_lookup()
{
//setup
var tvdbProvider = new TvDbProvider();
//act
var result = tvdbProvider.GetSeries("clone high");
//assert
Assert.IsNull(result);
}
[Test]
public void American_dad_fix()
{
//setup
var tvdbProvider = new TvDbProvider();
//act
var result = tvdbProvider.GetSeries(73141, true);
var seasons = result.Episodes.Select(e => e.SeasonNumber)
.Distinct().ToList();
var seasons1 = result.Episodes.Where(e => e.SeasonNumber == 1).ToList();
var seasons2 = result.Episodes.Where(e => e.SeasonNumber == 2).ToList();
var seasons3 = result.Episodes.Where(e => e.SeasonNumber == 3).ToList();
var seasons4 = result.Episodes.Where(e => e.SeasonNumber == 4).ToList();
var seasons5 = result.Episodes.Where(e => e.SeasonNumber == 5).ToList();
var seasons6 = result.Episodes.Where(e => e.SeasonNumber == 6).ToList();
foreach (var episode in result.Episodes)
{
Console.WriteLine(episode);
}
//assert
2011-06-02 21:06:46 +00:00
seasons.Should().HaveCount(7);
seasons1.Should().HaveCount(23);
seasons2.Should().HaveCount(19);
seasons3.Should().HaveCount(16);
seasons4.Should().HaveCount(20);
seasons5.Should().HaveCount(18);
seasons1.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems();
seasons2.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems();
seasons3.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems();
seasons4.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems();
seasons5.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems();
seasons6.Select(s => s.EpisodeNumber).Should().OnlyHaveUniqueItems();
}
2010-09-23 03:19:47 +00:00
}
2011-04-10 02:44:01 +00:00
}