Improve the fuzzy matching (#522)
* Fixed: improve track matching * Deal with tracks sequentially numbered across discspull/6/head
parent
8320508688
commit
e260a29b57
@ -0,0 +1,77 @@
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Moq;
|
||||
|
||||
namespace NzbDrone.Core.Test.MusicTests.AlbumRepositoryTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AlbumServiceFixture : CoreTest<AlbumService>
|
||||
{
|
||||
private List<Album> _albums;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_albums = new List<Album>();
|
||||
_albums.Add(new Album
|
||||
{
|
||||
Title = "ANThology",
|
||||
CleanTitle = "anthology",
|
||||
});
|
||||
|
||||
_albums.Add(new Album
|
||||
{
|
||||
Title = "+",
|
||||
CleanTitle = "",
|
||||
});
|
||||
|
||||
Mocker.GetMock<IAlbumRepository>()
|
||||
.Setup(s => s.GetAlbums(It.IsAny<int>()))
|
||||
.Returns(_albums);
|
||||
}
|
||||
|
||||
private void GivenSimilarAlbum()
|
||||
{
|
||||
_albums.Add(new Album
|
||||
{
|
||||
Title = "ANThology2",
|
||||
CleanTitle = "anthology2",
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase("ANTholog", "ANThology")]
|
||||
[TestCase("antholoyg", "ANThology")]
|
||||
[TestCase("ANThology CD", "ANThology")]
|
||||
[TestCase("ANThology CD xxxx (Remastered) - [Oh please why do they do this?]", "ANThology")]
|
||||
[TestCase("+ (Plus) - I feel the need for redundant information in the title field", "+")]
|
||||
public void should_find_album_in_db_by_inexact_title(string title, string expected)
|
||||
{
|
||||
var album = Subject.FindByTitleInexact(0, title);
|
||||
|
||||
album.Should().NotBeNull();
|
||||
album.Title.Should().Be(expected);
|
||||
}
|
||||
|
||||
[TestCase("ANTholog")]
|
||||
[TestCase("antholoyg")]
|
||||
[TestCase("ANThology CD")]
|
||||
[TestCase("÷")]
|
||||
[TestCase("÷ (Divide)")]
|
||||
public void should_not_find_album_in_db_by_inexact_title_when_two_similar_matches(string title)
|
||||
{
|
||||
GivenSimilarAlbum();
|
||||
var album = Subject.FindByTitleInexact(0, title);
|
||||
|
||||
album.Should().BeNull();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue