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