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