1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Fixed broken tests

This commit is contained in:
Mark McDowall 2013-01-24 00:03:10 -08:00
parent 0315385f98
commit 5af06c1332
2 changed files with 37 additions and 33 deletions

View File

@ -1,8 +1,4 @@
{ {
"version": "1.1", "status": false,
"error": { "error": "API Key Incorrect"
"name": "JSONRPCError",
"code": 1,
"message": "Invalid procedure"
}
} }

View File

@ -44,18 +44,17 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void GetSceneName_exists() public void GetSceneName_exists()
{ {
WithRealDb();
//Setup //Setup
var fakeMap = Builder<SceneMapping>.CreateNew() var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.CleanTitle = "laworder") .With(f => f.CleanTitle = "laworder")
.With(f => f.SeriesId = 12345) .With(f => f.SeriesId = 12345)
.With(f => f.SceneName = "Law and Order") .With(f => f.SceneName = "Law and Order")
.With(f => f.SeasonNumber = -1)
.Build(); .Build();
Db.Insert(fakeMap);
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act //Act
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId); var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
@ -67,6 +66,8 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void GetSeriesId_exists() public void GetSeriesId_exists()
{ {
WithRealDb();
//Setup //Setup
var fakeMap = Builder<SceneMapping>.CreateNew() var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.SeriesId = 12345) .With(f => f.SeriesId = 12345)
@ -74,11 +75,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder") .With(f => f.SceneName = "laworder")
.Build(); .Build();
Db.Insert(fakeMap);
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act //Act
var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle); var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
@ -90,6 +87,8 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void GetSceneName_null() public void GetSceneName_null()
{ {
WithRealDb();
//Setup //Setup
var fakeMap = Builder<SceneMapping>.CreateNew() var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.SeriesId = 12345) .With(f => f.SeriesId = 12345)
@ -97,11 +96,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder") .With(f => f.SceneName = "laworder")
.Build(); .Build();
Db.Insert(fakeMap);
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act //Act
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(54321); var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(54321);
@ -113,6 +108,8 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void GetSeriesId_null() public void GetSeriesId_null()
{ {
WithRealDb();
//Setup //Setup
var fakeMap = Builder<SceneMapping>.CreateNew() var fakeMap = Builder<SceneMapping>.CreateNew()
.With(f => f.SeriesId = 12345) .With(f => f.SeriesId = 12345)
@ -120,11 +117,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.CleanTitle = "laworder") .With(f => f.CleanTitle = "laworder")
.Build(); .Build();
Db.Insert(fakeMap);
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(emptyDatabase);
emptyDatabase.Insert(fakeMap);
//Act //Act
var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder"); var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder");
@ -136,6 +129,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void GetSceneName_multiple_clean_names() public void GetSceneName_multiple_clean_names()
{ {
WithRealDb();
//Test that ensures a series with clean names (office, officeus) can be looked up by seriesId //Test that ensures a series with clean names (office, officeus) can be looked up by seriesId
//Setup //Setup
@ -143,21 +137,18 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.CleanTitle = "office") .With(f => f.CleanTitle = "office")
.With(f => f.SeriesId = 12345) .With(f => f.SeriesId = 12345)
.With(f => f.SceneName = "The Office") .With(f => f.SceneName = "The Office")
.With(f => f.SeasonNumber = -1)
.Build(); .Build();
var fakeMap2 = Builder<SceneMapping>.CreateNew() var fakeMap2 = Builder<SceneMapping>.CreateNew()
.With(f => f.CleanTitle = "officeus") .With(f => f.CleanTitle = "officeus")
.With(f => f.SeriesId = 12345) .With(f => f.SeriesId = 12345)
.With(f => f.SceneName = "The Office") .With(f => f.SceneName = "The Office")
.With(f => f.SeasonNumber = -1)
.Build(); .Build();
Db.Insert(fakeMap);
Db.Insert(fakeMap2);
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
db.Insert(fakeMap);
db.Insert(fakeMap2);
//Act //Act
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId); var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
@ -166,6 +157,23 @@ namespace NzbDrone.Core.Test.ProviderTests
Assert.AreEqual(fakeMap.SceneName, sceneName); Assert.AreEqual(fakeMap.SceneName, sceneName);
} }
[Test]
public void GetSceneName_should_be_null_when_seasonNumber_does_not_match()
{
WithRealDb();
var fakeMap = Builder<SceneMapping>.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<SceneMappingProvider>().GetSceneName(54321, 5).Should().BeNull();
}
[Test] [Test]
public void UpdateMappings_should_add_all_mappings_to_database() public void UpdateMappings_should_add_all_mappings_to_database()
{ {