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

This commit is contained in:
Mark McDowall 2011-08-22 23:07:04 -07:00
parent 322767c3f3
commit fb9c2b6d9e
2 changed files with 34 additions and 1 deletions

View File

@ -102,5 +102,38 @@ namespace NzbDrone.Core.Test
//Assert
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);
}
}
}

View File

@ -72,7 +72,7 @@ namespace NzbDrone.Core.Providers
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)
return null;