|
|
@ -5,6 +5,7 @@ using NUnit.Framework;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.Music;
|
|
|
|
using NzbDrone.Core.Music;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.MusicTests.TitleMatchingTests
|
|
|
|
namespace NzbDrone.Core.Test.MusicTests.TitleMatchingTests
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -21,49 +22,82 @@ namespace NzbDrone.Core.Test.MusicTests.TitleMatchingTests
|
|
|
|
_trackService =
|
|
|
|
_trackService =
|
|
|
|
new TrackService(_trackRepository, Mocker.Resolve<ConfigService>(), Mocker.Resolve<Logger>());
|
|
|
|
new TrackService(_trackRepository, Mocker.Resolve<ConfigService>(), Mocker.Resolve<Logger>());
|
|
|
|
|
|
|
|
|
|
|
|
_trackRepository.Insert(new Track
|
|
|
|
var trackNames = new List<string> {
|
|
|
|
{
|
|
|
|
"Courage",
|
|
|
|
Title = "This is the short test title",
|
|
|
|
"Movies",
|
|
|
|
ForeignTrackId = "this is a fake id2",
|
|
|
|
"Flesh and Bone",
|
|
|
|
AlbumId = 4321,
|
|
|
|
"Whisper",
|
|
|
|
AbsoluteTrackNumber = 1,
|
|
|
|
"Summer",
|
|
|
|
MediumNumber = 1,
|
|
|
|
"Sticks and Stones",
|
|
|
|
TrackFileId = 1
|
|
|
|
"Attitude",
|
|
|
|
});
|
|
|
|
"Stranded",
|
|
|
|
|
|
|
|
"Wish",
|
|
|
|
_trackRepository.Insert(new Track
|
|
|
|
"Calico",
|
|
|
|
{
|
|
|
|
"(Happy) Death Day",
|
|
|
|
Title = "This is the long test title",
|
|
|
|
"Smooth Criminal",
|
|
|
|
ForeignTrackId = "this is a fake id",
|
|
|
|
"Universe / Orange Appeal"
|
|
|
|
AlbumId = 4321,
|
|
|
|
};
|
|
|
|
AbsoluteTrackNumber = 2,
|
|
|
|
|
|
|
|
MediumNumber = 1,
|
|
|
|
for (int i = 0; i < trackNames.Count; i++) {
|
|
|
|
TrackFileId = 2
|
|
|
|
_trackRepository.Insert(new Track
|
|
|
|
});
|
|
|
|
{
|
|
|
|
|
|
|
|
Title = trackNames[i],
|
|
|
|
|
|
|
|
ForeignTrackId = (i+1).ToString(),
|
|
|
|
|
|
|
|
AlbumId = 4321,
|
|
|
|
|
|
|
|
AbsoluteTrackNumber = i+1,
|
|
|
|
|
|
|
|
MediumNumber = 1,
|
|
|
|
|
|
|
|
TrackFileId = i+1
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_find_track_in_db_by_tracktitle_longer_then_relaeasetitle()
|
|
|
|
public void should_find_track_in_db_by_tracktitle_longer_then_releasetitle()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var track = _trackService.FindTrackByTitle(1234, 4321, 1, 1, "This is the short test title with some bla");
|
|
|
|
var track = _trackService.FindTrackByTitle(1234, 4321, 1, 1, "Courage with some bla");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
track.Should().NotBeNull();
|
|
|
|
track.Title.Should().Be(_trackRepository.GetTracksByFileId(1).First().Title);
|
|
|
|
track.Title.Should().Be(_trackRepository.GetTracksByFileId(1).First().Title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_find_track_in_db_by_tracktitle_shorter_then_relaeasetitle()
|
|
|
|
public void should_find_track_in_db_by_tracktitle_shorter_then_releasetitle()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var track = _trackService.FindTrackByTitle(1234, 4321, 1, 2, "test title");
|
|
|
|
var track = _trackService.FindTrackByTitle(1234, 4321, 1, 3, "and Bone");
|
|
|
|
|
|
|
|
|
|
|
|
track.Title.Should().Be(_trackRepository.GetTracksByFileId(2).First().Title);
|
|
|
|
track.Should().NotBeNull();
|
|
|
|
|
|
|
|
track.Title.Should().Be(_trackRepository.GetTracksByFileId(3).First().Title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void should_not_find_track_in_db_by_wrong_title()
|
|
|
|
public void should_not_find_track_in_db_by_wrong_title()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var track = _trackService.FindTrackByTitle(1234, 4321, 1, 1, "the short title");
|
|
|
|
var track = _trackService.FindTrackByTitle(1234, 4321, 1, 1, "Not a track");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
track.Should().BeNull();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase("Fesh and Bone", 3)]
|
|
|
|
|
|
|
|
[TestCase("Atitude", 7)]
|
|
|
|
|
|
|
|
[TestCase("Smoth cRimnal", 12)]
|
|
|
|
|
|
|
|
[TestCase("Sticks and Stones (live)", 6)]
|
|
|
|
|
|
|
|
public void should_find_track_in_db_by_inexact_title(string title, int trackNumber)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var track = _trackService.FindTrackByTitleInexact(1234, 4321, 1, trackNumber, title);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
track.Should().NotBeNull();
|
|
|
|
|
|
|
|
track.Title.Should().Be(_trackRepository.GetTracksByFileId(trackNumber).First().Title);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase("A random title", 1)]
|
|
|
|
|
|
|
|
[TestCase("Stones and Sticks", 6)]
|
|
|
|
|
|
|
|
public void should_not_find_track_in_db_by_different_inexact_title(string title, int trackId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var track = _trackService.FindTrackByTitleInexact(1234, 4321, 1, trackId, title);
|
|
|
|
|
|
|
|
|
|
|
|
track.Should().BeNull();
|
|
|
|
track.Should().BeNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|