mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 17:57:43 +00:00
Local series search will now search anywhere in the title, not just the beginning.
This commit is contained in:
parent
eb323b5394
commit
72c555f250
2 changed files with 48 additions and 6 deletions
|
@ -653,7 +653,53 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SearchForSeries_should_not_return_results_that_do_not_start_with_query()
|
public void SearchForSeries_should_return_results_that_contain_the_query()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||||
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||||
|
.WhereAll()
|
||||||
|
.Have(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
db.InsertMany(fakeSeries);
|
||||||
|
db.Insert(fakeQuality);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var series = mocker.Resolve<SeriesProvider>().SearchForSeries("itl");
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
series.Should().HaveCount(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SearchForSeries_should_return_results_that_end_with_the_query()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||||
|
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||||
|
.WhereAll()
|
||||||
|
.Have(e => e.QualityProfileId = fakeQuality.QualityProfileId)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
db.InsertMany(fakeSeries);
|
||||||
|
db.Insert(fakeQuality);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var series = mocker.Resolve<SeriesProvider>().SearchForSeries("2");
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
series.Should().HaveCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SearchForSeries_should_not_return_results_that_do_not_contain_the_query()
|
||||||
{
|
{
|
||||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||||
var db = MockLib.GetEmptyDatabase();
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
|
|
@ -190,11 +190,7 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
var query = String.Format(@"SELECT * FROM Series
|
var query = String.Format(@"SELECT * FROM Series
|
||||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
||||||
WHERE Title LIKE '{0}%'", title);
|
WHERE Title LIKE '%{0}%'", title);
|
||||||
|
|
||||||
// var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
|
|
||||||
// INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
|
||||||
// WHERE Title LIKE '@0%'", title);
|
|
||||||
|
|
||||||
var series = _database.Fetch<Series, QualityProfile>(query);
|
var series = _database.Fetch<Series, QualityProfile>(query);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue