Fixed SceneMappingProvider to resolve an issue with series with multiple clean names failing to return a Scene Name when being looked up via SeriesId.

pull/3113/head
Mark McDowall 13 years ago
parent 322767c3f3
commit fb9c2b6d9e

@ -102,5 +102,38 @@ namespace NzbDrone.Core.Test
//Assert //Assert
Assert.AreEqual(null, seriesId); Assert.AreEqual(null, seriesId);
} }
[Test]
public void GetSceneName_multiple_clean_names()
{
//Test that ensures a series with clean names (office, officeus) can be looked up by seriesId
//Setup
var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.CleanTitle = "office")
.With(f => f.SeriesId = 12345)
.With(f => f.SceneName = "The Office")
.Build();
var fakeMap2 = Builder<SceneMapping>.CreateNew()
.With(f => f.CleanTitle = "officeus")
.With(f => f.SeriesId = 12345)
.With(f => f.SceneName = "The Office")
.Build();
var mocker = new AutoMoqer();
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
db.Insert(fakeMap);
db.Insert(fakeMap2);
//Act
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
//Assert
Assert.AreEqual(fakeMap.SceneName, sceneName);
}
} }
} }

@ -72,7 +72,7 @@ namespace NzbDrone.Core.Providers
public virtual string GetSceneName(int seriesId) public virtual string GetSceneName(int seriesId)
{ {
var item = _database.SingleOrDefault<SceneMapping>("WHERE SeriesId = @0", seriesId); var item = _database.FirstOrDefault<SceneMapping>("WHERE SeriesId = @0", seriesId);
if (item == null) if (item == null)
return null; return null;

Loading…
Cancel
Save