2011-11-14 03:22:18 +03:00
|
|
|
|
2011-06-14 05:15:55 +03:00
|
|
|
using FizzWare.NBuilder;
|
2011-06-03 04:15:02 +03:00
|
|
|
using NUnit.Framework;
|
2011-06-14 05:15:55 +03:00
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-06-03 04:15:02 +03:00
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-11-14 03:22:18 +03:00
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
2011-06-03 04:15:02 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-11-13 10:27:16 +03:00
|
|
|
public class SceneMappingTest : CoreTest
|
2011-06-03 04:15:02 +03:00
|
|
|
{
|
2011-06-14 05:15:55 +03:00
|
|
|
[Test]
|
|
|
|
public void GetSceneName_exists()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-06-17 09:04:01 +03:00
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
|
|
|
.With(f => f.CleanTitle = "laworder")
|
2011-06-14 05:15:55 +03:00
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
2011-11-23 08:58:26 +03:00
|
|
|
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
|
2011-06-17 09:04:01 +03:00
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Act
|
2011-06-17 09:04:01 +03:00
|
|
|
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
|
|
|
}
|
2011-06-03 04:15:02 +03:00
|
|
|
|
|
|
|
[Test]
|
2011-06-14 05:15:55 +03:00
|
|
|
public void GetSeriesId_exists()
|
2011-06-03 04:15:02 +03:00
|
|
|
{
|
2011-06-14 05:15:55 +03:00
|
|
|
//Setup
|
2011-06-17 09:04:01 +03:00
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
2011-06-14 05:15:55 +03:00
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
|
|
|
.With(f => f.SceneName = "laworder")
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
2011-11-23 08:58:26 +03:00
|
|
|
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
|
2011-06-17 09:04:01 +03:00
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Act
|
2011-06-17 09:04:01 +03:00
|
|
|
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
Assert.AreEqual(fakeMap.SeriesId, seriesId);
|
2011-06-03 04:15:02 +03:00
|
|
|
}
|
|
|
|
|
2011-06-14 05:15:55 +03:00
|
|
|
[Test]
|
|
|
|
public void GetSceneName_null()
|
|
|
|
{
|
|
|
|
//Setup
|
2011-06-17 09:04:01 +03:00
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
2011-06-14 05:15:55 +03:00
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
2011-06-17 09:04:01 +03:00
|
|
|
.With(f => f.SceneName = "laworder")
|
2011-06-14 05:15:55 +03:00
|
|
|
.Build();
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
2011-11-23 08:58:26 +03:00
|
|
|
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
|
2011-06-17 09:04:01 +03:00
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Act
|
2011-06-17 09:04:01 +03:00
|
|
|
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(54321);
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
Assert.AreEqual(null, sceneName);
|
|
|
|
}
|
2011-06-03 04:15:02 +03:00
|
|
|
|
|
|
|
[Test]
|
2011-06-14 05:15:55 +03:00
|
|
|
public void GetSeriesId_null()
|
2011-06-03 04:15:02 +03:00
|
|
|
{
|
2011-06-14 05:15:55 +03:00
|
|
|
//Setup
|
2011-06-17 09:04:01 +03:00
|
|
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
2011-06-14 05:15:55 +03:00
|
|
|
.With(f => f.SeriesId = 12345)
|
|
|
|
.With(f => f.SceneName = "Law and Order")
|
2011-06-17 09:04:01 +03:00
|
|
|
.With(f => f.CleanTitle = "laworder")
|
2011-06-14 05:15:55 +03:00
|
|
|
.Build();
|
|
|
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
2011-11-23 08:58:26 +03:00
|
|
|
var emptyDatabase = TestDbHelper.GetEmptyDatabase();
|
2011-06-17 09:04:01 +03:00
|
|
|
mocker.SetConstant(emptyDatabase);
|
|
|
|
emptyDatabase.Insert(fakeMap);
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Act
|
2011-06-17 09:04:01 +03:00
|
|
|
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder");
|
2011-06-14 05:15:55 +03:00
|
|
|
|
|
|
|
//Assert
|
|
|
|
Assert.AreEqual(null, seriesId);
|
2011-06-03 04:15:02 +03:00
|
|
|
}
|
2011-08-23 09:07:04 +03:00
|
|
|
|
|
|
|
[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();
|
|
|
|
|
2011-11-23 08:58:26 +03:00
|
|
|
var db = TestDbHelper.GetEmptyDatabase();
|
2011-08-23 09:07:04 +03:00
|
|
|
mocker.SetConstant(db);
|
|
|
|
|
|
|
|
db.Insert(fakeMap);
|
|
|
|
db.Insert(fakeMap2);
|
|
|
|
|
|
|
|
//Act
|
|
|
|
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
|
|
|
}
|
2011-06-03 04:15:02 +03:00
|
|
|
}
|
|
|
|
}
|