diff --git a/NzbDrone.Core.Test/Files/JsonError.txt b/NzbDrone.Core.Test/Files/JsonError.txt index 3c937f046..aa32a0bdd 100644 --- a/NzbDrone.Core.Test/Files/JsonError.txt +++ b/NzbDrone.Core.Test/Files/JsonError.txt @@ -1,8 +1,4 @@ { - "version": "1.1", - "error": { - "name": "JSONRPCError", - "code": 1, - "message": "Invalid procedure" - } + "status": false, + "error": "API Key Incorrect" } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs index e83935baf..90cf36b2c 100644 --- a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs @@ -44,18 +44,17 @@ private void WithErrorDownloadingJson() [Test] public void GetSceneName_exists() { + WithRealDb(); + //Setup var fakeMap = Builder.CreateNew() .With(f => f.CleanTitle = "laworder") .With(f => f.SeriesId = 12345) .With(f => f.SceneName = "Law and Order") + .With(f => f.SeasonNumber = -1) .Build(); - - - var emptyDatabase = TestDbHelper.GetEmptyDatabase(); - Mocker.SetConstant(emptyDatabase); - emptyDatabase.Insert(fakeMap); + Db.Insert(fakeMap); //Act var sceneName = Mocker.Resolve().GetSceneName(fakeMap.SeriesId); @@ -67,6 +66,8 @@ public void GetSceneName_exists() [Test] public void GetSeriesId_exists() { + WithRealDb(); + //Setup var fakeMap = Builder.CreateNew() .With(f => f.SeriesId = 12345) @@ -74,11 +75,7 @@ public void GetSeriesId_exists() .With(f => f.SceneName = "laworder") .Build(); - - - var emptyDatabase = TestDbHelper.GetEmptyDatabase(); - Mocker.SetConstant(emptyDatabase); - emptyDatabase.Insert(fakeMap); + Db.Insert(fakeMap); //Act var seriesId = Mocker.Resolve().GetSeriesId(fakeMap.CleanTitle); @@ -90,6 +87,8 @@ public void GetSeriesId_exists() [Test] public void GetSceneName_null() { + WithRealDb(); + //Setup var fakeMap = Builder.CreateNew() .With(f => f.SeriesId = 12345) @@ -97,11 +96,7 @@ public void GetSceneName_null() .With(f => f.SceneName = "laworder") .Build(); - - - var emptyDatabase = TestDbHelper.GetEmptyDatabase(); - Mocker.SetConstant(emptyDatabase); - emptyDatabase.Insert(fakeMap); + Db.Insert(fakeMap); //Act var sceneName = Mocker.Resolve().GetSceneName(54321); @@ -113,6 +108,8 @@ public void GetSceneName_null() [Test] public void GetSeriesId_null() { + WithRealDb(); + //Setup var fakeMap = Builder.CreateNew() .With(f => f.SeriesId = 12345) @@ -120,11 +117,7 @@ public void GetSeriesId_null() .With(f => f.CleanTitle = "laworder") .Build(); - - - var emptyDatabase = TestDbHelper.GetEmptyDatabase(); - Mocker.SetConstant(emptyDatabase); - emptyDatabase.Insert(fakeMap); + Db.Insert(fakeMap); //Act var seriesId = Mocker.Resolve().GetSeriesId("notlaworder"); @@ -136,6 +129,7 @@ public void GetSeriesId_null() [Test] public void GetSceneName_multiple_clean_names() { + WithRealDb(); //Test that ensures a series with clean names (office, officeus) can be looked up by seriesId //Setup @@ -143,21 +137,18 @@ public void GetSceneName_multiple_clean_names() .With(f => f.CleanTitle = "office") .With(f => f.SeriesId = 12345) .With(f => f.SceneName = "The Office") + .With(f => f.SeasonNumber = -1) .Build(); var fakeMap2 = Builder.CreateNew() .With(f => f.CleanTitle = "officeus") .With(f => f.SeriesId = 12345) .With(f => f.SceneName = "The Office") + .With(f => f.SeasonNumber = -1) .Build(); - - - var db = TestDbHelper.GetEmptyDatabase(); - Mocker.SetConstant(db); - - db.Insert(fakeMap); - db.Insert(fakeMap2); + Db.Insert(fakeMap); + Db.Insert(fakeMap2); //Act var sceneName = Mocker.Resolve().GetSceneName(fakeMap.SeriesId); @@ -166,6 +157,23 @@ public void GetSceneName_multiple_clean_names() Assert.AreEqual(fakeMap.SceneName, sceneName); } + [Test] + public void GetSceneName_should_be_null_when_seasonNumber_does_not_match() + { + WithRealDb(); + + var fakeMap = Builder.CreateNew() + .With(f => f.SeriesId = 12345) + .With(f => f.SceneName = "Law and Order") + .With(f => f.SceneName = "laworder") + .With(f => f.SeasonNumber = 10) + .Build(); + + Db.Insert(fakeMap); + + Mocker.Resolve().GetSceneName(54321, 5).Should().BeNull(); + } + [Test] public void UpdateMappings_should_add_all_mappings_to_database() {