Lidarr/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs

93 lines
2.9 KiB
C#
Raw Normal View History

using System;
2015-01-09 01:43:51 +00:00
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Exceptions;
2015-01-09 01:43:51 +00:00
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource.SkyHook;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Music;
2015-01-09 01:43:51 +00:00
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.MetadataSource.SkyHook
{
[TestFixture]
[IntegrationTest]
public class SkyHookProxyFixture : CoreTest<SkyHookProxy>
{
[SetUp]
public void Setup()
{
UseRealHttp();
}
[TestCase("f59c5520-5f46-4d2c-b2c4-822eabf53419", "Linkin Park")]
[TestCase("66c662b6-6e2f-4930-8610-912e24c63ed1", "AC/DC")]
public void should_be_able_to_get_artist_detail(string mbId, string name)
2015-01-09 01:43:51 +00:00
{
var details = Subject.GetArtistInfo(mbId, 0);
2015-01-09 01:43:51 +00:00
ValidateArtist(details.Item1);
ValidateAlbums(details.Item2);
2015-01-09 01:43:51 +00:00
details.Item1.Name.Should().Be(name);
2015-01-09 01:43:51 +00:00
}
[Test]
public void getting_details_of_invalid_artist()
2015-01-09 01:43:51 +00:00
{
Assert.Throws<ArtistNotFoundException>(() => Subject.GetArtistInfo("aaaaaa-aaa-aaaa-aaaa", 0));
2015-01-09 01:43:51 +00:00
}
[Test]
public void should_not_have_period_at_start_of_name_slug()
2015-01-09 01:43:51 +00:00
{
var details = Subject.GetArtistInfo("b6db95cd-88d9-492f-bbf6-a34e0e89b2e5", 0);
2015-01-09 01:43:51 +00:00
details.Item1.NameSlug.Should().Be("dothack");
2015-01-09 01:43:51 +00:00
}
private void ValidateArtist(Artist artist)
2015-01-09 01:43:51 +00:00
{
artist.Should().NotBeNull();
artist.Name.Should().NotBeNullOrWhiteSpace();
2017-10-08 20:07:54 +00:00
artist.CleanName.Should().Be(Parser.Parser.CleanArtistName(artist.Name));
artist.SortName.Should().Be(Parser.Parser.NormalizeTitle(artist.Name));
artist.Overview.Should().NotBeNullOrWhiteSpace();
artist.Images.Should().NotBeEmpty();
artist.NameSlug.Should().NotBeNullOrWhiteSpace();
2015-01-09 01:43:51 +00:00
//series.TvRageId.Should().BeGreaterThan(0);
artist.ForeignArtistId.Should().NotBeNullOrWhiteSpace();
2015-01-09 01:43:51 +00:00
}
private void ValidateAlbums(List<Album> albums)
2015-01-09 01:43:51 +00:00
{
albums.Should().NotBeEmpty();
2015-01-09 01:43:51 +00:00
foreach (var episode in albums)
2015-01-09 01:43:51 +00:00
{
ValidateAlbum(episode);
2015-01-09 01:43:51 +00:00
//if atleast one album has title it means parse it working.
albums.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Title));
2015-01-09 01:43:51 +00:00
}
}
private void ValidateAlbum(Album album)
2015-01-09 01:43:51 +00:00
{
album.Should().NotBeNull();
album.Title.Should().NotBeNullOrWhiteSpace();
album.AlbumType.Should().NotBeNullOrWhiteSpace();
2015-01-09 01:43:51 +00:00
album.Should().NotBeNull();
2015-01-09 01:43:51 +00:00
if (album.ReleaseDate.HasValue)
2015-01-09 01:43:51 +00:00
{
album.ReleaseDate.Value.Kind.Should().Be(DateTimeKind.Utc);
2015-01-09 01:43:51 +00:00
}
}
}
}