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.
Lidarr/src/NzbDrone.Core.Test/MusicTests/ArtistServiceTests/FindByNameInexactFixture.cs

59 lines
1.7 KiB

using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Test.MusicTests.ArtistServiceTests
{
[TestFixture]
public class FindByNameInexactFixture : CoreTest<ArtistService>
{
private List<Artist> _artists;
private Artist CreateArtist(string name)
{
return Builder<Artist>.CreateNew()
.With(a => a.Name = name)
.With(a => a.CleanName = Parser.Parser.CleanArtistName(name))
.With(a => a.ForeignArtistId = name)
.BuildNew();
}
[SetUp]
public void Setup()
{
_artists = new List<Artist>();
_artists.Add(CreateArtist("The Black Eyed Peas"));
_artists.Add(CreateArtist("The Black Keys"));
Mocker.GetMock<IArtistRepository>()
.Setup(s => s.All())
.Returns(_artists);
}
[TestCase("The Black Eyde Peas", "The Black Eyed Peas")]
[TestCase("Black Eyed Peas", "The Black Eyed Peas")]
[TestCase("The Black eys", "The Black Keys")]
public void should_find_artist_in_db_by_name_inexact(string name, string expected)
{
var artist = Subject.FindByNameInexact(name);
artist.Should().NotBeNull();
artist.Name.Should().Be(expected);
}
[TestCase("The Black Peas")]
public void should_not_find_artist_in_db_by_ambiguous_name(string name)
{
var artist = Subject.FindByNameInexact(name);
artist.Should().BeNull();
}
}
}