1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 02:07:41 +00:00

SeriesPathExists compares paths in lower-case now.

GitHub Issue #9
This commit is contained in:
Mark McDowall 2011-07-28 18:03:24 -07:00
parent 23681167e4
commit 559011ba82
2 changed files with 126 additions and 1 deletions

View file

@ -10,6 +10,7 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
// ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test
@ -350,5 +351,129 @@ namespace NzbDrone.Core.Test
series.QualityProfile.Should().NotBeNull();
series.QualityProfileId.Should().Be(fakeQuality.QualityProfileId);
}
[Test]
public void SeriesPathExists_exact_match()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var path = @"C:\Test\TV\30 Rock";
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.WhereAll()
.Have(c => c.QualityProfileId = 1)
.WhereTheFirst(1)
.Have(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
db.InsertMany(fakeSeries);
db.Insert(fakeQuality);
//Act
mocker.Resolve<QualityProvider>();
//mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
//fakeSeries.ToList());
var result = mocker.Resolve<SeriesProvider>().SeriesPathExists(path);
//Assert
result.Should().BeTrue();
}
[Test]
public void SeriesPathExists_match()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var path = @"C:\Test\TV\30 Rock";
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.WhereAll()
.Have(c => c.QualityProfileId = 1)
.WhereTheFirst(1)
.Have(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
db.InsertMany(fakeSeries);
db.Insert(fakeQuality);
//Act
mocker.Resolve<QualityProvider>();
//mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
//fakeSeries.ToList());
var result = mocker.Resolve<SeriesProvider>().SeriesPathExists(path.ToUpper());
//Assert
result.Should().BeTrue();
}
[Test]
public void SeriesPathExists_match_alt()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var path = @"C:\Test\TV\The Simpsons";
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.WhereAll()
.Have(c => c.QualityProfileId = 1)
.WhereTheFirst(1)
.Have(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
db.InsertMany(fakeSeries);
db.Insert(fakeQuality);
//Act
mocker.Resolve<QualityProvider>();
//mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
//fakeSeries.ToList());
var result = mocker.Resolve<SeriesProvider>().SeriesPathExists(@"c:\Test\Tv\the sIMpsons");
//Assert
result.Should().BeTrue();
}
[Test]
public void SeriesPathExists_match_false()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var path = @"C:\Test\TV\30 Rock";
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.WhereAll()
.Have(c => c.QualityProfileId = 1)
.WhereTheFirst(1)
.Have(c => c.Path = path)
.Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
db.InsertMany(fakeSeries);
db.Insert(fakeQuality);
//Act
mocker.Resolve<QualityProvider>();
//mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Series, QualityProfile>(It.IsAny<string>())).Returns(
//fakeSeries.ToList());
var result = mocker.Resolve<SeriesProvider>().SeriesPathExists(@"C:\Test\TV\Not A match");
//Assert
result.Should().BeFalse();
}
}
}

View file

@ -178,7 +178,7 @@ namespace NzbDrone.Core.Providers
public virtual bool SeriesPathExists(string cleanPath)
{
if (GetAllSeries().Any(s => s.Path == cleanPath))
if (GetAllSeries().Any(s => s.Path.ToLower() == cleanPath.ToLower()))
return true;
return false;